Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


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

© 2015 Microsoft