Determine whether a command batch has changed the current database.
char *dbchange(dbproc) DBPROCESS *dbproc;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library uses to manage communications and data between the front end and server.
A pointer to the null-terminated name of the new database, if any. If the database has not changed, NULL will be returned.
dbchange informs the program of a change in the current database. It does so by catching any instance of the Transact-SQL use command.
Although a use command can appear anywhere in a command batch, the database change does not actually take effect until the end of the batch. dbchange is therefore useful only in determining whether the current command batch has changed the database for subsequent command batches.
The internal DBPROCESS flag that dbchange monitors to determine whether the database has changed is cleared when the program executes a new command batch by calling either dbsqlexec or dbsqlsend. Therefore, the simplest way to keep track of database changes is to call dbchange when dbresults returns NO_MORE_RESULTS at the end of each command batch.
Alternatively, you can always get the name of the current database by calling dbname.