dbnumcols

Determines the number of columns for the current result set.

Syntax

INT dbnumcols ( PDBPROCESS dbproc );

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.
Returns

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

Examples

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

  


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