RAD Studio VCL Reference
|
Provides the transaction in which the TAdoDbxCommand executes.
property Transaction: DbTransaction;
__property DbTransaction Transaction;
Transaction provides the transaction the command executes within. The transaction must already have been created prior to naming it with the Transaction property on the TAdoDbxCommand.
connection.Open(); TAdoDbxTransaction transaction = connection.BeginTransaction(); string textSQL = "INSERT INTO Employee (...) VALUES (...)"; TAdoDbxCommand command = new TAdoDbxCommand(textSQL, connection, transaction); int intRecordsAffected = command.ExecuteNonQuery(); if (intRecordsAffected == 1) { MessageBox.Show("Row updated."); transaction.Commit(); } else { // No records affected MessageBox.Show("No row updated."); transaction.Rollback(); }
connection.Open(); TTrans: TTransaction.BeginTransaction(connection); string textSQL = "INSERT INTO Employee (...) VALUES (...)"; TAdoDbxCommand command = new TAdoDbxCommand(textSQL, connection, TTrans); int intRecordsAffected = command.ExecuteNonQuery(); if (intRecordsAffected == 1) { MessageBox.Show("Row updated."); TTrans.Commit(); } else { // No records affected MessageBox("No row updated.", [smbOK]); TTrans.Rollback(); }
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|