different server name

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
biasko
Posts: 6
Joined: Thu 05 Oct 2006 20:55

different server name

Post by biasko » Wed 27 Dec 2006 19:24

Hello!

I have MyDAC in my project and I would like to read server name for MyConnection from some txt file and than make connect to databese. But I don't know how and when, because my program needs some data from database onShow.
Thanks!

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 28 Dec 2006 12:59

This may look like the code below:

Code: Select all

procedure TForm1.FormShow(Sender: TObject);
var
  s: string;
begin
  // reading a server name to s
  MyConnection.Server := s;
  MyConnection.Username := 'user';
  MyConnection.Password := 'password';
  MyConnection.Port := 3306;
  MyConnection.Database := 'test';
  MyConnection.Connect;
end;

biasko
Posts: 6
Joined: Thu 05 Oct 2006 20:55

Post by biasko » Wed 03 Jan 2007 19:51

I recieve error (ACESS VIOLATION AT ADRESS 00599303 IN MODEULE 'project.exe'. READ OF ADRESS 000000A0.)

Thanks for help!

biasko
Posts: 6
Joined: Thu 05 Oct 2006 20:55

Post by biasko » Wed 03 Jan 2007 19:54

oh..I found out.. i must put this code ONSHOW

Post Reply