All of the c-tree Plus Data Access components indicate error conditions by raising an exception of type ECtError. ECtError is a class derived from the Borland Exception Handling class, thus all normal VCL exception handling routines will work when handling ECtError exceptions. It is generally best to have a user-defined function, perhaps named ShowException(), that is called when an exception is caught to display the error message and number. "Component Reference" has more information on ECtError.
This particular sample shows the setting of some important properties to c-tree Plus. The three initial properties set are the server name, user name and user password. They are required for a client/server application and are ignored for a stand-alone application. The fourth property, Directory, indicates the directory where the session dictionary (in this sample) will be created. Other Session properties are described in the component reference chapter.
Delphi Example
procedure Form1.CreateNewSession;
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.CreateSession();
except
on E : ECtError do
Application.ShowException(E);
end;
end;
C++ Example
void Form1::CreateNewSession()
{
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->CreateSession();
}
catch (ECtError& E)
{
Application->ShowException(&E);
}
}