dbcolname

DB Library for C

DB Library for C

dbcolname

Returns a pointer to the null-terminated name of a particular result column.

Syntax

LPCSTR dbcolname (
PDBPROCESS
dbproc,
INT
column );

Arguments

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.

Returns

A char pointer to the null-terminated name of the particular column. If the column number is not in range or if the column is the result of an expression with no name assigned, dbcolname returns NULL. If the column number is out of range, dbcolname also calls the error handler with an error of 10011 (SQLECNOR).

Examples

The following example shows how to use dbcolname:

DBPROCESS   *dbproc;

// Put the command into the command buffer. 
dbcmd(dbproc, "SELECT name, id, type FROM sysobjects");

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

// Process the command results. 
dbresults(dbproc);

// Examine the column names. 
printf("first column name is %s\n", dbcolname(dbproc, 1));
printf("second column name is %s\n", dbcolname(dbproc, 2));
printf("third column name is %s\n", dbcolname(dbproc, 3));

See Also

dbcollen

dbdatlen

dbcoltype

dbnumcols

dbdata