Connecting to a databaseBefore performing any operations with a database, a database object must be connected to a session by calling CTDatabase::Connect() method. The database should already have been created or added to the session. // connect to a database CTDatabase ADatabase(ASession); try {
ADatabase.Connect(“MyDatabase”); catch (CTException &err) {
} When a database is connected to the session, it is considered “active”. Use CTDatabase::IsActive() to check if a particular database is active. When the database connection is no longer needed, it must be disconnected from the session by calling CTDatabase::Disconnect() method. // disconnect from a database try {
ADatabase.Disconnect(); } catch (CTException &err) {
err.GetErrorCode()); } |
|||