Product Documentation

VCL/CLX Developers Guide

Previous Topic

Next Topic

Log On to c-tree

Before any c-tree Plus database or table operations can be performed by an application, it is necessary to log on to a c-tree session.

To log on to a c-tree session at design time, execute the following steps:

  1. Drop a TCtSession component on the form.
  2. Set the Server, User and Password properties with the appropriate values.
  3. Set the Directory if the Session dictionary has been created in a directory other than the default directory
  4. Set the Active property to True.

When the connection to the c-tree session is no longer necessary, log off by setting the Active property to False (design time) or by calling the Logout() method. A session dictionary must exist in the specified location for a log on operation to be successful. See “Creating a new session” to learn how to create a session dictionary.

To log on to a c-tree session at run time, execute the following steps, after the TCtSession component has been dropped on the form:

  1. Set the Server, User and Password properties with the appropriate values.
  2. Set the Directory if the Session dictionary has been created in a directory other than the default directory
  3. Set the Active property to True or call the Logon method.

The sequences below represent the run time logon to the session dictionary in Delphi and C++.

Delphi Example


procedure Form1.LogonToServer;

begin

try

CtSession1.Server := 'FAIRCOMS';

CtSession1.User := 'ADMIN';

CtSession1.Password := 'ADMIN';

{$IFDEF WIN32} // Windows path

CtSession1.Directory := 'C:\Data';

{$ELSE} // Linux path

CtSession1.Directory := '/home/Data';

{$ENDIF}

CtSession1.Logon();

except

on E : ECtError do

Application.ShowException(E);

end;

end;

C++ Example


void Form1::LogonToSession()

{

try

{

CtSession1->Server = "FAIRCOMS";

CtSession1->User = "ADMIN";

CtSession1->Password = "ADMIN";

#ifdef__WIN32__ // Windows path

CtSession1->Directory = "C:\\Data";

#else // Linux path

CtSession1->Directory = "/home/Data";

#endif

CtSession1->Active = True;

}

catch (ECtError& E)

{

Application->ShowException(&E);

}

}

In the examples discussed above, the default value for some properties like Bufs, Dbufs, Fils, Sect, Tag, and UserProf were not modified. The default value for these properties is enough for most applications, though the advanced user may fine-tune an application using custom values. See the discussion for each of these properties in "Component Reference". This chapter has more information on TCtSession and the related methods, properties and events.

TOCIndex