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:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\ODBC\Compute\Debug
Compute
SQLAllocHandle | SQLDisconnect | SQLNumResultCols |
SQLBindCol | SQLExecDirect | SQLSetEnvAttr |
SQLColAttribute | SQLFetch | SQLSetStmtAttr |
SQLConnect | SQLFreeHandle | |
SQLDescribeCol | SQLGetDiagRec |