我試圖抓住約從我的分貝特定用戶的信息:asp.net數據庫返回只有一個值,而不是一整套
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;
}
}
的問題是,它僅返回第一個表數據(以這個案例lastName),我知道我可以爲每個字段編寫單獨的查詢,但我認爲這不會很有效。
有無論如何得到這個數據與一個查詢?
對不起,我的標籤(自動完成)。任何方式非常感謝史蒂夫幫助解決我的問題100%。 +1 – molu2008