CODBCStmt.ColAttributemethod
Returns descriptor information for a column in a result set.
Syntax
FUNCTION ColAttribute (BYVAL ColumnNumber AS SQLUSMALLINT, BYVAL FieldIdentifier AS SQLUSMALLINT, BYVAL CharacterAttribute AS SQLPOINTER, BYVAL BufferLength AS SQLSMALLINT, BYVAL StringLength AS SQLSMALLINT PTR, BYVAL NumericAttribute AS ANY PTR) AS SQLRETURN
Parameters
| Name | Description | |
|---|---|---|
ColumnNumber | The number of the record in the IRD from which the field value is to be retrieved. This argument corresponds to the column number of result data, ordered sequentially in increasing column order, starting at 1. Columns can be described in any order. Column 0 can be specified in this argument, but all values except SQL_DESC_TYPE and SQL_DESC_OCTET_LENGTH will return undefined values. | |
FieldIdentifier | The field in row ColumnNumber of the IRD that is to be returned. | |
CharacterAttribute | Pointer to a buffer in which to return the value in the FieldIdentifier field of the ColumnNumber row of the IRD, if the field is a character string. Otherwise, the field is unused. | |
BufferLength | If FieldIdentifier is an ODBC-defined field and CharacterAttribute points to a character string or binary buffer, this argument should be the length of CharacterAttribute. If FieldIdentifier is an ODBC-defined field and CharacterAttribute is an integer, this field is ignored. If FieldIdentifier is a driver-defined field, the application indicates the nature of the field to the Driver Manager by setting the BufferLength argument. BufferLength can have the following values:
| |
StringLength | Pointer to a buffer in which to return the total number of bytes (excluding the null-termination byte for character data) available to return in CharacterAttribute. For character data, if the number of bytes available to return is greater than or equal to BufferLength, the descriptor information in CharacterAttribute is truncated to BufferLength minus the length of a null-termination character and is null-terminated by the driver. For all other types of data, the value of BufferLength is ignored and the driver assumes the size of CharacterAttribute is 32 bits or 64 bits. | |
NumericAttribute | Pointer to an integer buffer in which to return the value in the FieldIdentifier field of the ColumnNumber row of the IRD, if the field is a numeric descriptor type, such as SQL_DESC_COLUMN_LENGTH. Otherwise, the field is unused. |
Return value
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.
Description
Returns descriptor information for a column in a result set. Descriptor information is returned as a character string, a 32-bit descriptor-dependent value, or an integer value.
Example
#include once "AfxNova/COdbc.inc" USING AfxNova
' // Create a connection object and connect with the database DIM wszConStr AS WSTRING * 260 = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=biblio.mdb" DIM pDbc AS CODBC = wszConStr IF pDbc.Handle = NULL THEN PRINT "Unable to create the connection handle" : SLEEP : END
' // Allocate an statement object DIM pStmt AS COdbcStmt = @pDbc IF pStmt.Handle = NULL THEN PRINT "Unable to create 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 SHORT = pStmt.NumResultCols PRINT "Number of columns:" & STR(numCols) IF numCols = 0 THEN PRINT "There are no columns": SLEEP : END ' // Retrieve the names of the fields (columns) FOR idx AS LONG = 1 TO numCols PRINT "Field #" & STR(idx) & " name: " & pStmt.ColName(idx) NEXT ' // Parse the result set DO ' // Fetch the record IF pStmt.Fetch = FALSE THEN EXIT DO ' // Get the values of the columns and display them FOR idx AS LONG = 1 TO numCols
PRINT pStmt.GetData(idx)
NEXT LOOP
Reference
- Include file
CODBCStmt.inc - Defined in AfxNova/COdbcStmt.inc:814
- Documented in Databases/ODBC Classes/CODBCStmt Class.md
- Topic: CODBCStmt Class