MySql connection not working.
Posted: Mon 06 Dec 2010 13:51
Hello,
I am trying to connect to a MySQL database and its not working.
When I type all of the information into TUniConnection that I drop onto the main form it works, however when I create one in code and fill out the parameters with the same information it fails
It fails when it tries to connect, and the problem I am seeing is that instead of trying to connect to the IP provided it tries to connect to the IP of my companies modem. I assume there is something I am not setting correctly considering it works through component when i drop it on the form but not in my code.
NOTE: The result is the same no matter if I set the port or not.
Thank you for your help,
Tim
I am trying to connect to a MySQL database and its not working.
When I type all of the information into TUniConnection that I drop onto the main form it works, however when I create one in code and fill out the parameters with the same information it fails
Code: Select all
Conn := TUniConnection.Create(self);
Conn.ProviderName:= 'MySQL';
Conn.Username:='username';
Conn.Password:= 'Password'
Conn.Server := '97.75.23.17';
Conn.Database:= 'mydatabase';
// Conn.Port := 3306;
Conn.Connect;
if Conn.Connected then
begin
tbl := TUniTable.Create(Self);
tbl.Connection := Conn;
tbl.TableName := 'Test';
tbl.Open;
tbl.FindFirst;
ShowMessage(tbl.FieldByName('idTest').AsString);
end;
Conn.Close;
NOTE: The result is the same no matter if I set the port or not.
Thank you for your help,
Tim