Previous Topic

Next Topic

Find Database by UID

ctdbFindDatabaseByUID() locates a database given the database UID and retrieves the database name and path. ctdbFindDatabaseByUID() requires a session or database handle. The following example shows how to implement a database connect procedure using the database UID instead of the database name.

/* Database Connect using UID */
CTDBRET ConnectByUID(CTHANDLE hDatabase, ULONG uid)
{
   TEXT dbName[MAX_NAME];
   TEXT dbPath[MAX_PATH];
   CTDBRET Retval;

   Retval = ctdbFindDatabaseByUID(hDatabase, uid, dbName, sizeof(dbName), Path,
            sizeof(dbPath));
   if (Retval == CTDBRET_OK)
   {
      Retval = ctdbConnect(hDatabase, dbName);
   }
   return Retval;
}