CODBCStmt.BindColToBitmethod
Syntax
FUNCTION BindColToBit (BYVAL ColNumber AS SQLUSMALLINT, BYVAL TargetValue AS SHORT PTR, BYVAL StrLen_or_IndPtr AS ANY PTR) AS SQLRETURN
BindCol — one description covers them all.Parameters
| Name | Description | |
|---|---|---|
ColNumber | Number of the result set column to bind. Columns are numbered in increasing column order starting at 0, where column 0 is the bookmark column. If bookmarks are not used — that is, the SQL_ATTR_USE_BOOKMARKS statement attribute is set to SQL_UB_OFF — then column numbers start at 1. | |
TargetValue | Pointer to the data buffer to bind to the column. Fetch and FetchScroll return data in this buffer. BulkOperations returns data in this buffer when Operation is SQL_FETCH_BY_BOOKMARK; it retrieves data from this buffer when Operation is SQL_ADD or SQL_UPDATE_BY_BOOKMARK. SetPos returns data in this buffer when Operation is SQL_REFRESH; it retrieves data from this buffer when Operation is SQL_UPDATE. If TargetValue is a null pointer, the driver unbinds the data buffer for the column. An application can unbind all columns by calling UnbindColumns or FreeStmt with the SQL_UNBIND option. An application can unbind the data buffer for a column but still have a length/indicator buffer bound for the column, if the TargetValue argument in the call to BindCol is a null pointer but the StrLen_or_IndPtr argument is a valid value. | |
StrLen_or_IndPtr | Pointer to the length/indicator buffer to bind to the column. Fetch and FetchScroll return a value in this buffer. BulkOperations retrieves a value from this buffer when Operation is SQL_ADD, SQL_UPDATE_BY_BOOKMARK, or SQL_DELETE_BY_BOOKMARK. BulkOperations returns a value in this buffer when Operation is SQL_FETCH_BY_BOOKMARK. SetPos returns a value in this buffer when Operation is SQL_REFRESH; it retrieves a value from this buffer when Operation is SQL_UPDATE. Fetch, FetchScroll, BulkOperations, and SetPos can return the following values in the length/indicator buffer:
If StrLen_or_IndPtr is a null pointer, no length or indicator value is used. This is an error when fetching data and the data is NULL. |
Return value
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE, or SQL_ERROR.
Description
Binds application data buffers to columns in the result set.
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 ' // Bind the columns DIM AS LONG lAuId, cbAuId pStmt.BindCol(1, @lAuId, @cbAuId) DIM wszAuthor AS WSTRING * 260, cbAuthor AS LONG pStmt.BindCol(2, @wszAuthor, SIZEOF(wszAuthor), @cbAuthor) DIM iYearBorn AS SHORT, cbYearBorn AS LONG pStmt.BindCol(3, @iYearBorn, @cbYearBorn)
' // Generate a result set pStmt.ExecDirect ("SELECT * FROM Authors ORDER BY Author")
' // Parse the result set DIM dwsOutput AS DWSTRING DO ' // Fetch the record IF pStmt.Fetch = FALSE THEN EXIT DO ' // Get the values of the columns and display them dwsOutput = "" dwsOutput += pStmt.GetData(1) & " " dwsOutput += pStmt.GetData(2) & " " dwsOutput += pStmt.GetData(3) PRINT dwsOutput LOOP
Reference
- Include file
CODBCStmt.inc - Defined in AfxNova/COdbcStmt.inc:530
- Documented in Databases/ODBC Classes/CODBCStmt Class.md
- Topic: CODBCStmt Class