110,502
社区成员
发帖
与我相关
我的任务
分享
using (SqlCommand cmd = con.CreateCommand())
{
SqlTransaction tran = con.BeginTransaction();
cmd.Transaction = tran;
try
{
foreach (string item in strSQL)
{
cmd.CommandText = item;
cmd.ExecuteNonQuery();
}
tran.Commit();//如果都成功那么提交事物
}
catch (Exception ex)
{
index = -1;
//throw new Exception(ex.Message);
tran.Rollback();
}
//index = com.ExecuteNonQuery();
}