We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


Call this member function to retrieve the name of the currently connected database (provided that the data source defines a named object called "database").

CString GetDatabaseName( ) const;

A CString containing the database name if successful; otherwise, an empty CString.

This is not the same as the data source name (DSN) specified in the OpenEx or Open call. What GetDatabaseName returns depends on ODBC. In general, a database is a collection of tables. If this entity has a name, GetDatabaseName returns it.

You might, for example, want to display this name in a heading. If an error occurs while retrieving the name from ODBC, GetDatabaseName returns an empty Cstring.

Header: afxdb.h