Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Creating a Session Object

A valid session object is required to perform any session operation. The default parameter of the CTSession constructor is SESSION_TYPE.CTDB_SESSION.


// create a default CTSession object

CTSession ASession = new CTSession();

try

{

// logon to session using default

// server name, user name and password.

CTSession.Logon();

}

catch (CTException err)

{

Console.Write("Session logon failed with error {0}", err.GetErrorCode());

}


When a session object is created, we can specify the session type. There are three different session types:

SESSION_TYPE.CTREE_SESSION

Allocate a new session for logon only. No session or database dictionary files will be used. No database functions can be used with this session mode. You must allocate table handles using the session handle.

SESSION_TYPE.CTDB_SESSION

Allocate a new session making full usage of c-treeDB .NET session and database dictionaries. With this session mode, a Session dictionary file must exist to perform a session logon and you need to connect to a database before attempting to perform operation on tables.

SESSION_TYPE.SQL_SESSION

Allocate a new session for FairCom DB SQL processing. This session type is available with certain restrictions.

Example


// Create a session object

CTSession ASession = new CTSession(SESSION_TYPE.CTDB_SESSION);


TOCIndex