dbdata

Returns a pointer to the data for a result column.

Syntax

LPCBYTE dbdata (
PDBPROCESS
dproc,
INT
column );

Arguments
dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ Microsoft® 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 dbcoltype
dbcollen dbdatlen
dbcolname dbnumcols

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.