CDaoDatabase::GetName

CString GetName( );
throw( CDaoException, CMemoryException );

Return Value

The full path and filename for the database if successful; otherwise, an empty CString.

Remarks

Call this member function to retrieve the name of the currently open database, which is the name of an existing database file or registered ODBC data source name. If your network supports the uniform naming convention (UNC), you can also specify a network path, such as “\\\\MYSERVER\\MYSHARE\\MYDIR\\MYDB.MDB”. (Double backslashes are required in string literals because “\” is the C++ escape character.)

You might, for example, want to display this name in a heading. If an error occurs while retrieving the name, MFC throws an exception of type CDaoException.

Important   For better performance when accessing external databases, it is recommended that you attach external database tables to a Microsoft Jet engine database (.MDB) rather than connecting directly to the data source.

The database type is indicated by the file or directory that the path points to, as follows:

Pathname points to.. Database type
.MDB file Microsoft Jet database (Microsoft Access)
Directory containing .DBF file(s) dBASE® database
Directory containing .XLS file Microsoft Excel database
Directory containing .DBF files(s) Microsoft FoxPro® database
Directory containing .PDX file(s) Paradox® database
Directory containing appropriately formatted text database files Text format database

For ODBC databases, such as Microsoft SQL Server and Oracle®, the database’s connect string identifies a data source name (DSN) registered by ODBC.

For more about attaching external tables, see the article DAO External: Attaching External Tables in Visual C++ Programmer's Guide.

CDaoDatabase OverviewClass MembersHierarchy Chart

See Also   CDatabase::Open, CDatabase::GetConnect