dbcolsource

DB Library for C

DB Library for C

dbcolsource

Returns a pointer to the name of the database column from which the specified result column was derived.

Syntax

LPCSTR dbcolsource (
PDBPROCESS dbproc,
INT colnum );

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.

colnum

Is the number of the result column. The first column is number 1.

Returns

A pointer to a null-terminated column name. This pointer is NULL if the column number is out of range or if the column is the result of a Transact-SQL expression, such as MAX(colname).

Remarks

The dbcolsource function is one of the DB-Library browse-mode functions. This function gives an application the information it needs to update a database column, based on an ad hoc query. SELECT statements can optionally specify header names for result columns. For example:

SELECT author = au_lname FROM authors FOR BROWSE

When updating a table, you must use the database column name, not the header name (in this example, au_lname, not author). You can use the dbcolsource function if FOR BROWSE is issued on a view and to get the underlying database column name. For example:

dbcolsource(dbproc, 1)

This call returns a pointer to the string au_lname.

The dbcolsource function is useful for ad hoc queries. If the query has been hardcoded into the program, this function is unnecessary.

The dbcolsource function can be called any time after dbresults returns SUCCEED.

See Also

dbqual

dbtsnewlen

dbresults

dbtsnewval

dbtabbrowse

dbtsput

dbtabcount

Programming with DB-Library for C

dbtabname

Browse Mode

dbtabsource