Returns a pointer to the data for a result column.
LPCBYTE dbdata (
PDBPROCESS dproc,
INT column );
dbproc
Is the DBPROCESS structure that is the handle for a particular workstation or Microsoft® SQL Server™ 2000 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.
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.
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.
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);
}