May 2002
Beginner to intermediate
560 pages
11h 36m
English
The IDbConnection interface has a single method to begin a local transaction. This method returns an instance of a class that implements IDbTransaction. Classes such as SqlTransaction and OleDbTransaction implement IDbTransaction, which encapsulates operations involving a local transaction such as Commit and Rollback. You can configure the transaction isolation level through an optional parameter of IDbConnection.BeginTransaction. A simple transaction is shown in Listing 3-26.
SqlConnection sconn = new SqlConnection( "server=(local);uid=sa;pwd=mypw;database=pubs"); SqlCommand cmd = new SqlCommand( "insert jobs values('First', 10, 10)", sconn); SqlTransaction tx = null; try { sconn.Open(); ... |