CODBCStmt.NumResultColsmethod
Returns the number of columns in a result set.
Syntax
FUNCTION NumResultCols () AS SQLSMALLINT
Return value
The number of columns in a result set.
Result value (GetLastResult)
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.
Description
Returns the number of columns in a result set.
Example
#include once "AfxNova/COdbc.inc" USING AfxNova
' // Connect with the database DIM wszConStr AS WSTRING * 260 = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=biblio.mdb" DIM pDbc AS CODBC = wszConStr
' // Allocate an statement object DIM pStmt AS COdbcStmt = @pDbc IF pStmt.Handle = NULL THEN PRINT "Failed to allocate the statement handle": SLEEP : END
' // Cursor type pStmt.SetMultiuserKeysetCursor
' // Generate a result set pStmt.ExecDirect ("SELECT * FROM Authors ORDER BY Author")
' // Retrieve the number of columns DIM numCols AS SQLSMALLINT = pStmt.NumResultCols PRINT "Number of columns:" & STR(numCols)
' // Retrieve the names of the fields (columns) FOR idx AS LONG = 1 TO numCols PRINT "Field #" & STR(idx) & " name: " & pStmt.ColName(idx) NEXT
Reference
- Include file
CODBCStmt.inc - Defined in AfxNova/COdbcStmt.inc:150
- Documented in Databases/ODBC Classes/CODBCStmt Class.md
- Topic: CODBCStmt Class