The compute sample illustrates handling the multiple result sets that occur when an application executes a Transact-SQL SELECT statement containing a COMPUTE clause.
The sample executes a statement, and then uses SQLMoreResults and SQLColAttribute to determine the shape of each result set generated.
The sample shows how to mix array and single-row binding for rapid and space-efficient handling of the output.
Before compiling the compute sample, open the project and locate these lines in compute.cpp:
PTSTR szDataSource = _T("MyDatasource");
PTSTR szUID = _T("MyUID");
PTSTR szPWD = _T("MyPwd");
Replace the strings:
After compiling and linking the sample, run it by specifying its name at the command prompt:
cd C:\Mssql7\Devtools\Samples\ODBC\Compute\Release compute
Compute.mak contains nmake configurations for ANSI and Unicode debug and release versions of the sample.
Build target | CFG parameter | Output directory |
---|---|---|
ANSI debug | “Compute - Win32 Debug” | Debug |
ANSI release | “Compute - Win32 Release” | Release |
Unicode debug | “Compute - Win32 Unicode Debug” | Debug |
Unicode release | “Compute - Win32 Unicode Release” | Release |
SQLAllocHandle | SQLDisconnect | SQLNumResultCols |
SQLBindCol | SQLExecDirect | SQLSetEnvAttr |
SQLColAttribute | SQLFetch | SQLSetStmtAttr |
SQLConnect | SQLFreeHandle | |
SQLDescribeCol | SQLGetDiagRec |