Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

Using Transactions

As with ODBC transactions, OLE DB transactions can be used to control updates to a database and to erase recent changes, if needed. To enable transactions, you use the CSession class of your CCommand. For CCommand objects generated by the ATL Object Wizard, a CSession class variable, m_session, is defined for you. To enable a transaction for a rowset, simply invoke the CSession.StartTransaction() method:

CEmployee m_Set;
m_Set.m_session.StartTransaction();

To commit a transaction, use the CSession.Commit() method:

m_Set.m_session.Commit();

To roll back a transaction, use the CSession.Abort() method:

m_Set.m_session.Abort();

Share ThisShare This

Informit Network