在传统的ADO.NET中使用事务,方法如下:
Execute( connectionString) { (SqlConnection connection = SqlConnection(connectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; transaction = connection.BeginTransaction(); command.Connection = connection; command.Transaction = transaction; { command.CommandText =; command.ExecuteNonQuery(); transaction.Commit(); ...... } (Exception ex) { transaction.Rollback(); ..... } } }