function TryConnect(ADOConnection: TADOConnection;SVName,DBName,UserID,PassWD:String): Boolean;
begin
with ADOConnection do begin
Connected := False;
ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;User ID='
+UserID+';PWD='+PassWD+';Initial Catalog='+DBName+';Data Source='+SVName;
try
Connected := True;
except
if MessageBox(Application.Handle,'Error for Database Link!','Information',
MB_ICONWARNING+MB_RETRYCANCEL)<>IDRETRY then Break;
end;
Result := Connected;
end;
end;