Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbConnect

Connect to a database.

Declaration

CTDBRET ctdbConnect(CTHANDLE Handle, pTEXT Name)

Description

ctdbConnect() connects a database handle to a database. Connecting to a database makes that database "active." Before using this function to connect to a particular database, you must first allocate the database handle and associate it with a session by calling the ctdbAllocDatabase() function. In other words, after allocating a database handle and associating it with a session, use this function to select which database in the session the database handle manipulates. The application must connect a database before doing any operation with that database's tables.

  • Handle [in] the database handle, previously allocated with ctdbAllocDatabase().
  • Name [in] the database name. This database must have been previously added to the session with ctdbAddDatabase().

To disconnect a database from session, use the functions ctdbDisconnect() or ctdbDisconnectAll().

Returns

ctdbConnect() returns CTDBRET_OK on success, or the c-tree error code on failure.

Example

CTHANDLE hMyDatabase;

hMyDatabase = ctdbAllocDatabase(hMySession);

eRet = ctdbConnect(hMyDatabase, database_name);

See also

ctdbAllocDatabase(), ctdbDisconnect(), ctdbDisconnectAll(), ctdbCreateDatabase()

TOCIndex