- public static bool cmdTransaction(string[] sql)
- {
- SqlTransaction sqlTran = Con.BeginTransaction();
- SqlCommand cmd = new SqlCommand();
- cmd.Connection = Con;
- cmd.Transaction = sqlTran;
- try
- {
- foreach (string strSql in sql)
- {
- cmd.CommandText = strSql;
- cmd.ExecuteNonQuery();
- }
- sqlTran.Commit();
- return true;
- }
- catch
- {
- sqlTran.Rollback();
- return false;
- }
- }
复制代码 |