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)
{
StringBuilder dbName = new StringBuilder();
StringBuilder dbPath = new StringBuilder();
CTDatabase Retval = null;
if (ASession.FindDatabase(uid, out dbName, out dbPath)
{
Retval = new CTDatabase(ASession);
if (Retval != null)
{
Retval.Connect(dbName);
}
else
{
throw CTException(CTDBRET_NOMEMORY);
}
}
else
{
throw CTException(FNOP_ERR);
}
return Retval;
}