這是我的語法,但我得到的錯誤試圖填補數據表
SelectCommand屬性錯誤調用「補」之前尚未初始化。
爲了能夠填充數據表,我需要做些什麼?
using (SqlConnection conn = new SqlConnection("Server=Test;Database=Test;Integrated Security=SSPI;"))
{
SqlCommand command = new SqlCommand();
command.CommandText = "SELECT * FROM [dbo].[selfservice] WHERE saleID = @userid;";
command.Parameters.Add("@userid", SqlDbType.VarChar);
command.Parameters["@userid"].Value = row.Field<string>("saleID");
command.Connection = conn;
using (SqlDataAdapter dataadapter1 = new SqlDataAdapter()
{
dataadapter1.Fill(dtData);
}
}
標記爲答案,如果它有幫助 – Sajeetharan