public static string GetUserDetails(string stringInput, int displayoption) { if (stringInput == "") { return strErrorMessage_GetUserDetails; } else { string strUserName = ""; string strName = ""; string strReturnString = ""; string query1 = "SELECT user_name, first_name, last_name FROM users where user_id = '" + stringInput + "'"; // strReturnString = "<p>" + query1 + "</p>"; using (SqlConnection conn1 = new SqlConnection(connString)) { using (SqlCommand cmd1 = new SqlCommand(query1, conn1)) { conn1.Open(); SqlDataReader rdr1 = cmd1.ExecuteReader(); if (rdr1.HasRows) { while (rdr1.Read()) { strUserName = rdr1["user_name"].ToString(); strName = rdr1["first_name"].ToString() + " " + rdr1["last_name"].ToString(); switch (displayoption) { case 1: strReturnString = strReturnString + strUserName; break; case 2: strReturnString = strReturnString + strName + " (" + strUserName + ")"; break; default: strReturnString = strReturnString + strName + " (" + strUserName + " " + stringInput + ")"; break; } } } } } return strReturnString; }
Last Updated on October 26, 2015