Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to connect DBExpress at Runtime Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Change a connection string or database path to set a dataset 30-Aug-04
Category
dbExpress
Language
Kylix All Versions
Views
629
User Rating
8
# Votes
1
Replies
0
Publisher:
Kleiner, Max
Reference URL:
max@kleiner.com
			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   var 
4     Connection : TSQLConnection; 
5     DataSet    : TSQLDataSet; 
6   begin 
7     Connection:= TSQLConnection.Create(nil); 
8     with Connection do begin 
9       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 do begin 
22      SQLConnection:= Connection; 
23      CommandText:= Format('INSERT INTO t_runmax VALUES("%s","%s","%s")', 
24                               [Email,FirstN,LastN]); 
25      try 
26        ExecSQL; 
27      except 
28      end; 
29    end; 
30    Connection.Close; 
31    DataSet.Free; 
32    Connection.Free; 
33  end; 
34  


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC