using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=物流数据库;Integrated Security=True"))
{
conn.Open();
SqlCommand cmd = new SqlCommand("Delete from T_CheLiang where id=id", conn);
cmd.ExecuteNonQuery();
conn.Close();
this.Close(); }上面这样写 直接把 表里的资料都删掉我想按行删除
id=@id 报错啊!
SqlCommand cmd = new SqlCommand("Delete from T_CheLiang where id="+id, conn);
SqlCommand cmd = new SqlCommand("Delete from T_CheLiang where id=@id", conn);
{
int id=0;
conn.Open();
SqlCommand cmd = new SqlCommand("Delete from T_CheLiang where id="+id, conn);
cmd.ExecuteNonQuery();
conn.Close();
this.Close(); }