The document is archived and information here might be outdated


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;

Return Value

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.

See Also

CDatabase Overview | Class Members | Hierarchy Chart | CDatabase::OpenEx | CDatabase::Open | CDatabase::GetConnect

© 2016 Microsoft