Hi
what is the best way to check if the SQLserver is ready to establish a connection from a client?
Thanks for your answer
Peter
checkk if SQL Sever is ready for client connection
-
AndreyZ
Re: checkk if SQL Sever is ready for client connection
Hello,
The only way to check if SQL Server is available and allows connecting to it, is to make a connection attempt. Here is a code example:
The only way to check if SQL Server is available and allows connecting to it, is to make a connection attempt. Here is a code example:
Code: Select all
var
con: TUniConnection;
begin
con := TUniConnection.Create(nil);
try
try
con.ProviderName := 'SQL Server';
con.Server := 'server';
con.Database := 'database';
con.Username := 'username';
con.Password := 'password';
con.LoginPrompt := False;
con.Open;
ShowMessage('SQL Server is available');
except
on E: Exception do
ShowMessage(E.Message);
end;
finally
con.Free;
end;
end;-
AndreyZ
Re: checkk if SQL Sever is ready for client connection
Feel free to contact us if you have any further questions about UniDAC.