Working with Linux means from time to time to handle with text- or configuration
files at runtime so there is no way to manipulate a component at design time.
The normal way for Delphi and Kylix is just to check a dbExpress configuration
file, put a TSQLConnection on a form then double-click the TSQLConnection to
display the Connection Editor (property editor) and set parameter values (database
path, connection name etc.) to indicate the settings.
But in the following example, all goes by runtime (path and login) with dbExpress
we don't need an alias or the BDE either to open a dataset.
Password could be encrypted in a follow up function or driven by user input.
1 2 procedure TVCLScanner.PostUser(const Email, FirstName, LastName: WideString);
3 var4 Connection : TSQLConnection;
5 DataSet : TSQLDataSet;
6 begin7 Connection:= TSQLConnection.Create(nil);
8 with Connection dobegin9 ConnectionName:= 'VCLScanner';
10 DriverName:= 'INTERBASE';
11 LibraryName:= 'dbexpint.dll';
12 VendorLib:= 'GDS32.DLL';
13 GetDriverFunc:= 'getSQLDriverINTERBASE';
14 Params.Add('User_Name=SYSDBA');
15 Params.Add('Password=masterkey');
16 Params.Add('Database=milo2:D:\frank\webservices\umlbank.gdb');
17 LoginPrompt:= False;
18 Open;
19 end;
20 DataSet:= TSQLDataSet.Create(nil);
21 with DataSet dobegin22 SQLConnection:= Connection;
23 CommandText:= Format('INSERT INTO t_runmax VALUES("%s","%s","%s")',
24 [Email,FirstN,LastN]);
25 try26 ExecSQL;
27 except28 end;
29 end;
30 Connection.Close;
31 DataSet.Free;
32 Connection.Free;
33 end;
34