Would the following work? :
try
PQConnection1.HostName :='1.1.1.1';
messagedlg('Trying to connect to 1.1.1.1 ',mtinformation,[mbok],0);
SQlquery1.Active:= true;
Except on E: EDatabaseError do
begin
messagedlg('Could not connect to 1.1.1.1, Trying to connect to 1.1.1.2 ',mtinformation,[mbok],0);
SQLquery1.Active:=false;
PQConnection1.HostName :='1.1.1.2';
try
SQlquery1.Active:= true;
Except on E: EDatabaseError do
begin
messagedlg('Could not connect to 1.1.1.2, Trying to connect to 1.1.1.3',mtinformation,[mbok],0);
SQLquery1.Active:=false;
PQConnection1.HostName :='1.1.1.3';
try
SQlquery1.Active:= true;
Except on E: EDatabaseError do
begin
messagedlg('Could not connect to 1.1.1.3, tried all three IP addresses - no connection found - closing program ',mtinformation,[mbok],0);
SQLquery1.Active:=false;
form1.close;
application.Terminate;
end;
end;
end;
end;
end;
end;