asp.net.ph

SqlConnection.CommitTransaction Method

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 ( )

Exceptions


Exception Type Condition
Exception An error occured while trying to execute the transaction.

Remarks

Notes to Inheritors: When overriding CommitTransaction in a derived class, be sure to call the base class's CommitTransaction method.

Example

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 ( );
}
See Also

SqlConnection Members   BeginTransaction   SaveTransaction   RollbackTransaction Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph