Setting hostname during runtime?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Kongo
Posts: 2
Joined: Wed 31 Mar 2010 10:26

Setting hostname during runtime?

Post by Kongo » Wed 31 Mar 2010 10:35

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?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 01 Apr 2010 07:13

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;

Kongo
Posts: 2
Joined: Wed 31 Mar 2010 10:26

Works!

Post by Kongo » Thu 01 Apr 2010 11:22

I had a feeling the solution would be easy, thank you! :D

Post Reply