In actual applications, the program may need to automatically create BDE aliases.
Create MSSQL and Paradox database alias
// Unit code
Unit unit11; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, dbtables; Type tform11 = Class (tform) mmo1: tmemo; btn1: tbutton; Procedure btn1click (Sender: tobject); Private {private Declarations} public {public declarations} end; var form11: tform11; implementation {$ R *. DFM} procedure tform11.btn1click (Sender: tobject); var lst: tstringlist; Procedure dropalias (const aliasname: string); begin if lst. indexof (aliasname) <>-1 then begin session. deletealias (aliasname); Session. saveconfigfile; mmo1.lines. add ('drop alias ['+ aliasname +'] '); end; Procedure addparadox (const aliasname: string); begin dropalias (aliasname); try session. addstandardalias (aliasname, 'c: \ instance1', 'paradox '); Session. saveconfigfile; // Save the BDE configuration file mmo1.lines. add ('Save alias ['+ aliasname +'] '); does t on E: exception do application. messageBox (pchar (E. message), 'error', mb_iconerror + mb_ OK); end; Procedure addmssql (const aliasname: string); const serverstr = '. '; // server address (local) var aliaslst: tstringlist; begin dropalias (aliasname); try session. addstandardalias (aliasname, '', 'mssql'); Session. saveconfigfile; aliaslst: = tstringlist. create; try with aliaslst do begin add ('user name = Sa'); add ('sqlqrymode = Server'); add ('server name = '+ serverstr ); add ('database name = test'); end; Session. modifyalias (aliasname, aliaslst); Session. saveconfigfile; mmo1.lines. add ('Save alias ['+ aliasname +'] '); finally aliaslst. free; end; begin t on E: exception do application. messageBox (pchar (E. message), 'error', mb_iconerror + mb_ OK); end; begin lst: = tstringlist. create; try session. getaliasnames (LST); // get the alias list // paradox addparadox ('newparadox '); // mssq addmssql ('newsql'); finally lst. free; end.