我創建了一些簡單的代碼,但它看起來像是我的插入工作出錯我得到有關「where」的錯誤。我做錯了什麼?插入sql錯誤(「where」)
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(
"insert into dbo.UserInfo (Login, Password, UserType, ID) where Login [email protected] and [email protected] and [email protected] ", con);
{
cmd.Parameters.AddWithValue("@Login",TextBox1.Text);
cmd.Parameters.AddWithValue("@Password", TextBox2.Text+".123");
cmd.Parameters.AddWithValue("@Type", DropDownList1.SelectedValue);
int rows = cmd.ExecuteNonQuery();
con.Close();
}
錯誤是什麼? – Gajendra
關鍵字'where'附近的語法錯誤。 – user2121038
如果您嘗試更新一行或使用where子句,請使用update而不是insert – insomniac