/// <summary>
/// 利用事务执行Sql语句
/// </summary>
public static bool RunSqlTransaction(List<string> sql_str)
{
bool result = false;
SqlConnection myConnection = new SqlConnection(CONN_STRING);
// 初始化
myConnection.Open();
SqlCommand myCommand = myConnection.CreateCommand();
SqlTransaction myTrans;
// 开启
myTrans = myConnection.BeginTransaction();
// Both Transaction object and transaction object
myCommand.Connection = myConnection;
myCommand.Transaction = myTrans;
try
{
for (int i = 0; i < sql_str.Count; i++)
{
myCommand.CommandText = sql_str[i];
myCommand.ExecuteNonQuery();
}
myTrans.Commit();