Skip Headers
Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 2 (10.2)

Part Number B14308-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

GetConnectString Method

Applies To

OConnection

ODatabase

Description

This method returns the username that was used to connect to the Oracle database.

Usage

const char *GetConnectString(void) const

Remarks

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 the database name.

The string that is returned is owned by the object. The caller should not free it; it will be freed when the object is destroyed. On error, a NULL is returned.

Return Value

A valid, null terminated const char pointer on success; NULL on failure.

Example

This example opens the database and then looks at the connect string.

// construct & open a database object

ODatabase odb("ExampleDB", "scott/tiger", 0);

if (odb.IsOpen())

{ // let's look at the connect string

const char *cstring = odb.GetConnectString();

// cstring should be "scott"

}