删除数据库中的数据,为什么不成功,求指教!
String connString = "Data Source =STRING\\STRING;Initial Catalog = Employee; Integrated Security =SSPI";SqlConnection conn = new SqlConnection(connString);
conn.Open();
String dss = string.Format("SELECT * FROM zhanghao");
SqlDataAdapter da = new SqlDataAdapter(dss,conn);
DataSet ds = new DataSet();
da.Fill(ds, "zhanghao");
string del = string.Format("DELETE FROM zhanghao where id=123");
SqlCommand cmd = new SqlCommand(del);
da.DeleteCommand = cmd;
da.Update(ds, "zhanghao");
ds.Tables["zhanghao"].AcceptChanges();
conn.Close();