ADO.NET事务
在C#中直接使用SQL事务
string conString = "";
SqlConnection conn = new SqlConnection(conString);
conn.Open();
SqlTransaction tran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.Transaction = tran;
try
{
cmd.CommandText = "";
........
cmd.CommandText = "";
.......
tran.Commit();
}
catch
{
tran.Rollback();
}
finally
{
conn.Close()
}