System.Data.SqlClient Namespace SqlConnection Class
Commits the database transaction.
[ VB ]
Overrides Public Sub CommitTransaction ( )
[ C# ]
public override void CommitTransaction ( );
[ C++ ]
public: void CommitTransaction ( );
[ JScript ]
public override function CommitTransaction ( )
Exception Type |
Condition |
Exception |
An error occured while trying to execute the transaction. |
Notes to Inheritors: When overriding CommitTransaction in a derived class, be sure to call the base class's CommitTransaction method.
The following example initializes an SqlConnection, opens it, begins a transaction, commits the transaction, then closes the connection. To accomplish this, the method is passed an SQL connection string to use to connect to the data source.
void RunSqlTransaction ( string strConn ) {
SqlConnection myConn = new SqlConnection ( strConn );
myConn.Open ( );
myConn.BeginTransaction ( );
myConn.CommitTransaction ( );
myConn.Close ( );
}
SqlConnection Members BeginTransaction SaveTransaction RollbackTransaction