datagridview 有两行数据,一行正确,一行错误,用SqlDataAdapter.update(table) 插入数据,
一行插入,一行没有插入,有什么方法让两行数据都不能插入,或者插入的一行回滚?
我已经用了事物如下:
SqlTransaction tx = con.BeginTransaction();
apdate.UpdateCommand = new SqlCommand();
apdate.UpdateCommand.Transaction = tx;
try
{
apdate.Update(tabl);
}
catch
{
MessageBox.Show("运行错误");
tx.Rollback();
return;
}