Wednesday, March 2, 2011

How to add database aliases to BDE at run time

Here's a function that will let you add database aliases to BDE (Borland Database engine) during run time.

uses DBIProcs, DBITypes;

procedure AddBDEAlias(
  sAliasName,
  sAliasPath,
  sDBDriver : string );
var
  h : hDBISes;
begin;
  DBIInit( nil );
  DBIStartSession( 'dummy', h, '' );
  DBIAddAlias( nil,
    PChar( sAliasName ),
    PChar( sDBDriver ),
    PChar( 'PATH:' + sAliasPath ),
    True );
  DBICloseSession( h );
  DBIExit;
end;
For example, if you want to create an alias called WORK_DATA that points to the C:\WORK\DATA directory and use DBASE driver as the default database driver:
AddBDEAlias(
'WORK_DATA',
'C:\WORK\DATA',
'DBASE' );

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum