c# 对数据库的删除操作 执行后并没有删除 求帮助
stringconn="DataSource=DESKTOP-QEVLLTJ;InitialCatalog=企业人事管理系统;IntegratedSecurity=Tru...
string conn = "Data Source=DESKTOP-QEVLLTJ;Initial Catalog=企业人事管理系统;Integrated Security=True";
string del = string.Format("delete from 职工账号表$ where user='{0}'",textBox37.Text.Trim());
SqlConnection MySqlConnection = new SqlConnection(conn);
SqlCommand cmd = new SqlCommand(del, MySqlConnection);
MySqlConnection.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.DeleteCommand = cmd;
cmd.ExecuteNonQuery(); 展开
string del = string.Format("delete from 职工账号表$ where user='{0}'",textBox37.Text.Trim());
SqlConnection MySqlConnection = new SqlConnection(conn);
SqlCommand cmd = new SqlCommand(del, MySqlConnection);
MySqlConnection.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.DeleteCommand = cmd;
cmd.ExecuteNonQuery(); 展开
1个回答
展开全部
可能你没有用ExecuteNonQuery();
例:
SqlConnection lj = new SqlConnection("连接字符串");
lj.Open();
SqlCommand cx = new SqlCommand("update [NEW] set new_image_name='"+newfilr+"' where new_ID="+TextBox3.Text+"", lj);*/
///ExecuteNonQuery()方法执行操作
cx.ExecuteNonQuery();
例:
SqlConnection lj = new SqlConnection("连接字符串");
lj.Open();
SqlCommand cx = new SqlCommand("update [NEW] set new_image_name='"+newfilr+"' where new_ID="+TextBox3.Text+"", lj);*/
///ExecuteNonQuery()方法执行操作
cx.ExecuteNonQuery();
追问
用了 最后一行就是
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询