Product Documentation

c-treeDB API for C++ - Developers Guide

Previous Topic

Next Topic

Find Database by UID

The overloaded method CTSession::FindDatabase() locates a database given the database UID and retrieves the database name and path. The following example shows how to implement a database connect procedure using the database UID instead of the database name.

// Database Connect using UID

CTDatabase* ConnectByUID(CTSession &ASession, ULONG uid)

{

CTString dbName;

CTString dbPath;

CTDatabase *Retval = NULL;

if (ASession.FindDatabase(uid, dbName, dbPath)

{

Retval = new CTDatabase(ASession);

if (Retval)

{

Retval->Connect(dbName);

}

else

{

throw CTException(CTDBRET_NOMEMORY);

}

}

else

{

throw CTException(FNOP_ERR);

}

return Retval;

}

TOCIndex