|Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 1 (10.1)
Part Number B10119-01
This method returns the name of the database to which this connection is connected.
const char *GetDatabaseName(void) const
You need three things to connect to an Oracle database: the database name, the username, and the password. GetConnectString returns the username. The password is not available because, for security reasons, the class library (and its implementation objects) do not keep the password. OConnection::GetDatabaseName and ODatabase::GetName return a pointer to the database name.
It is possible for several database objects to share a connection. However, they will not share a connection unless they have the same database name.
The actual memory that the pointer points to is managed by the object. It should not be freed by the caller. It will be freed when the object is destroyed or closed.
A valid, null terminated const char pointer on success; NULL on failure.
This example gets the database name.
// we start with a dynaset named empdyn (which is open)
// get the dynaset's connection
OConnection tempconn = empdyn.GetConnection();
// now get the database name
const char *dbname = tempconn.GetDatabaseName();
Note that we must use dbname (or copy it) before tempcon goes out of scope, because tempconn's destructor will free the string.