dbnumcols

Determines the number of columns for the current results set.

Syntax

INT dbnumcols ( PDBPROCESS dbproc );

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.

Returns

The number of columns in the current results set. If there are no columns, 0 is returned. Call dbnumcols after dbresults has returned SUCCEED.

Example

The following program fragment shows how to use dbnumcols:

int        column_count;
DBPROCESS    *dbproc;

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

// Send the commands to SQL Server and start execution 
dbsqlexec(dbproc);

// Process each command until there are no more 
while (dbresults(dbproc) != NO_MORE_RESULTS)
{
    column_count = dbnumcols(dbproc);
    printf("%d columns in this SQL Server result.\n", column_count);
    while (dbnextrow(dbproc) != NO_MORE_ROWS)
        printf("row received.\n");
}

See Also

dbcollen, dbcolname