First we need to open a connection to a database by providing the FairCom Database Engine with a user name, password and the database name.
Below is the code for Initialize():
//
// Initialize()
//
// Perform the minimum requirement of logging onto the c-tree Server
//
static void Initialize()
{
Console.WriteLine("INIT");
try
{
// This section is only needed for the AppServer DLL model.
bool AppServerModel = true;
if (AppServerModel)
{
// Set c-tree database engine configuration file name.
CTSession.SetConfigurationFile("ctsrvr.cfg");
// Start c-tree database engine.
CTSession.StartDatabaseEngine();
}
// allocate objects
MySession = new CTSession(SESSION_TYPE.CTREE_SESSION);
MyTable = new CTTable(MySession);
MyRecord = new CTRecord(MyTable);
}
catch(CTException E)
{
Handle_Exception(E);
}
try
{
// connect to server
Console.WriteLine("\tLogon to server...");
MySession.Logon("FAIRCOMS", "", "");
}
catch(CTException E)
{
Handle_Exception(E);
}
}