System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection();
System.Data.SqlClient.SqlTransaction tran = new System.Data.SqlClient.SqlTransaction();
System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand("插入sql",con);
try
{
com.Transaction = tran;
con.BeginTransaction();
//执行多条更新语句
tran.Commit();
}
catch(System.Exception ex)
{
tran.Rollback();
}
System.Data.SqlClient.SqlTransaction tran = new System.Data.SqlClient.SqlTransaction();
System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand("插入sql",con);
try
{
com.Transaction = tran;
con.BeginTransaction();
//执行多条更新语句
tran.Commit();
}
catch(System.Exception ex)
{
tran.Rollback();
}