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 );

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

dbcolbrowse, dbqual, dbresults, dbtabbrowse, dbtabcount, dbtabname, dbtabsource, dbtsnewlen, dbtsnewval, dbtsput; Browse Mode, Programming with DB-Library, Bulk-Copy Functions