dbchange

Determines whether a command batch has changed the current database to another database.

Syntax

LPCSTR dbchange ( 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

A pointer to the null-terminated name of the new database, if any. If the database has not changed, NULL is returned.

Remarks

The dbchange function informs the program of a switch from one database to another by catching any instance of the Transact-SQL USE statement.

When connected to SQL Server version 4.2, a USE statement does not take effect until the end of the batch. The dbchange function is therefore useful only in determining whether the current command batch has changed to another database for subsequent command batches. The simplest way to keep track of database switches is to call dbchange when dbresults returns NO_MORE_RESULTS at the end of each command batch.

When connected to SQL Server 6.0 and later, a USE statement takes effect immediately.

Alternatively, you can always get the name of the current database by calling dbname.

See Also
dbname dbsqlsend
dbresults dbuse
dbsqlexec  

  


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