Cursors and Transactions, Data Entry and Concurrency

The cursor sample illustrates using Microsoft® SQL Server™ cursors to allow concurrent access to data on a server running SQL Server. The sample shows three methods of concurrent data access:

A dialog box, available when no document windows are open, allows the user to select the method of concurrency control to be used by the application.

The sample relies on data shipped with the ODBC 3.x samples. The data can be installed using the LoadData sample and the Lddist.cmd file. For more information about Lddist.cmd, see ODBC Samples.

The sample is a Microsoft Foundation Class MDI application. Each MDI window contains a property sheet of customer data from a fictitious bank. The window is implemented on a separate connection to the database so that a single user can experiment with various concurrency handling methods from a single instance of the application.

Customers at the bank can have one or two accounts and you can either deposit or withdraw funds from a customer’s checking or savings account. Each transaction inserts a row into an activity file and then attempts a positioned update of a balance item for the account. If the balancing transaction fails, the activity file insert is rolled back.

To open a connection, select File\New from the menu.

Build Configurations

Tran.mak contains nmake configurations for versions of the sample that support MS DTC and that do not support MS DTC. All versions are ANSI only.

Build target CFG parameter Output directory
ANSI debug “Tran - Win32 Debug” Debug
ANSI release “Tran - Win32 Release” Release
MS DTC debug “Tran - Win32 MS DTC Debug” DTC_Dbg
MS DTC release “Tran - Win32 MS DTC Release” DTC_Rel

Functions Illustrated
SQLAllocHandle SQLDriverConnect SQLGetDiagRec
SQLBindParameter SQLEndTran SQLNumResultCols
SQLCloseCursor SQLExecDirect SQLSetConnectAttr
SQLColAttribute SQLFetch SQLSetEnvAttr
SQLDataSources SQLFreeHandle SQLSetPos
SQLDescribeCol SQLGetCursorName SQLSetStmtAttr
SQLDisconnect SQLGetDiagField  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.