I'm trying to grab information about a particular user from my db:
public string GetUserData()
{
string conString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(conString))
{
SqlCommand com = new SqlCommand("SELECT lastName , phoneNo , creditCardNo , dateOfBirth FROM UserExtendedDataSet WHERE UserId = @UserId", con);
com.Parameters.Add("@UserId", SqlDbType.NVarChar).Value = getUserId();
con.Open();
string result = Convert.ToString(com.ExecuteScalar());
StatusLabel.Text = result;
return result;
}
}
The problem is that it returns only the first table data (in this case lastName), i know that I can write separate queries for each field but I assume this would not be really efficient.
Is there anyway to get this data with one query ?