Page 1 of 1

Setting hostname during runtime?

Posted: Wed 31 Mar 2010 10:35
by Kongo
Hi all,

Im sure this question has been answered before, but i have searched and could not find it.
Im converting an old project of mine to use dbExpress instead of an older mysql component i've used.
The problem is i cant seem to be able to set hostname, username password etc. during runtime?
I've been trying to set it using SQLConnection1.Driver.HostName:='localhost'; but that wont compile, stating that 'TSQLConnection does not contain a member named 'driver'' even though the object inspector would suggest that it does.

What am I doing wrong?

Posted: Thu 01 Apr 2010 07:13
by Dimon
To specify hostname, port, username and password you should set the appropriate parameters of TSQLConnection, like this:

Code: Select all

  SQLConnection1.Params.Values['HostName'] := HostName;
  SQLConnection1.Params.Values['Port'] := Port;
  SQLConnection1.Params.Values['UserName'] := UserName;
  SQLConnection1.Params.Values['Password'] := Password;

Works!

Posted: Thu 01 Apr 2010 11:22
by Kongo
I had a feeling the solution would be easy, thank you! :D