Page 1 of 1

Socket error on connect how to raise with Friendly message

Posted: Fri 18 May 2007 15:09
by Daniel Fagnan
We received this message when I lost the connection on the server is off

Can`t Connect to MySQL on '192.168.1.141' (10061)
Socker Error on connect. WSAgetlastError return 10065($2751)

This message is raise with a beep ,I would like to intercept and show a
friendly messsagebox display and continue with the application and retry in 2 min.

Posted: Sat 19 May 2007 11:24
by swierzbicki
Just catch the exception on the myconnection onerror event handler.
See the faq for more details.

Posted: Mon 21 May 2007 07:59
by Antaeus
Another way to solve this problem is to add an OnError event handler to your TMyConnection object. It may look like this:

Code: Select all

uses
  MyCall;

....
procedure TForm1.MyConnectionError(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
  if e.ErrorCode = CR_CONN_HOST_ERROR then begin
    ShowMessage('Cannot connect');
    Fail := False;
  end;
end;

OnError event handler - abort?

Posted: Mon 21 May 2007 17:39
by oldmanus
retry, retry, retry......
connect abort? disconnect, kill connection? etc.? :?:

please example....

Re: OnError event handler - abort?

Posted: Wed 23 May 2007 09:30
by Antaeus
oldmanus wrote:retry, retry, retry......
connect abort? disconnect, kill connection? etc.? :?:

please example....
Please describe the problem in more detail. What example do you mean?

Posted: Wed 23 May 2007 13:20
by Antaeus
You may be interested in Disconnected Model and Local Failover functionality of MyDAC. See the "Working in an unstable network" topic in MyDAC Help for more information. The FailOver demo demonstrates how does this functionality work. This demo accompanies MyDAC, and is located in the MyDAC installation directory.