dbdata

Returns a pointer to the data for a result column.

Syntax

LPCBYTE dbdata (
PDBPROCESS
dproc,
INT
column );

where

dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ SQL Server process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
column
Is the number of the column. The first column is number 1. For further information, see "dbadata."

Returns

A BYTE pointer to the data for the column. A NULL BYTE pointer is returned if there is no such column or if the data has a null value. To make sure that the data is really a null value, check for a return of 0 from dbdatlen.

Remarks

The data is not null-terminated. To get the length of the data, use dbdatlen.

The dbbind function automatically binds data to your program variables. It is often easier to use than dbdata, but it makes a copy of the data. Call dbdata only after dbnextrow or dbgetrow has returned reg_row.

Example

The following example shows how to use dbdata:

DBPROCESS    *dbproc;
DBINT        row_number = 0;
DBINT        object_id;

// Put the command into the command buffer. 
dbcmd(dbproc, "select id from sysobjects");

// Send the command to SQL Server and begin execution. 
dbsqlexec(dbproc);

// Process the command results. 
dbresults(dbproc);
// Examine the data in each row. 
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
    row_number+;
    object_id = *((DBINT *)dbdata(dbproc, 1));
    printf("row %ld, object id is %ld.\n", row_number, object_id);
}

See Also

dbbind, dbcollen, dbcolname, dbcoltype, dbdatlen, dbnumcols