Product Documentation

dbExpress Driver (dBX)

Previous Topic

Next Topic

Init

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():

procedure TForm1.Init;

var

ininame : string;

reg : TRegistry;

ini : TIniFile;

begin

// retrieve the driver ini file

reg := TRegistry.Create;

try

Reg.RootKey := HKEY_CURRENT_USER;

if Reg.OpenKey('\Software\Borland\DBExpress', True) then

begin

ininame := Reg.ReadString('Driver Registry File');

Reg.CloseKey;

end;

finally

reg.free;

end;

// retrieve the LibraryName and VendorLib from ini file

ini := TIniFile.Create(ininame);

try

SQLConnection1.LibraryName := ini.ReadString('ctreeDBX', 'LibraryName', 'ctreedbx.dll');

SQLConnection1.VendorLib := ini.ReadString('ctreeDBX', 'VendorLib', 'ctesql.dll');

finally

ini.free;

end;

// connect to server

SimpleDataSet1.Active := false;

SQLConnection1.Connected := true;

end;

TOCIndex