Product Documentation

c-treeDB API for C# - Developers Guide

Previous Topic

Next Topic

Working with Sessions without Dictionary Support

There may be situations where it is necessary to operate with a table that does not belong to a database, or where a session or database dictionary file is not required. For these situations the user may want to create a session object of type SESSION_TYPE.CTREE_SESSION.


// create a session object without dictionary support

CTSession ASession = new CTSession(SESSION_TYPE.CTREE_SESSION);

// Logon to a session

try

{

ASession.Logon("FAIRCOMS", "ADMIN", "ADMIN");

}

catch (CTException err)

{

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

}

The CTSession.Logon() call above will perform a c-tree logon but it will not attempt to open a session dictionary file. The same result is obtained if a normal SESSION_TYPE.CTDB_SESSION or SESSION_TYPE.SQL_SESSION session is allocated but the method CTSession.SetLogonOnly() is called before CTSession.Logon().


// create a session object without dictionary support

CTSession ASession = new CTSession();


// Logon to a session

try

{

ASession.SetLogonOnly();

ASession.Logon("FAIRCOMS", "ADMIN", "ADMIN");

}

catch (CTException err)

{

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

}


TOCIndex