Socket error on connect how to raise with Friendly message

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Daniel Fagnan
Posts: 58
Joined: Fri 13 Oct 2006 00:08

Socket error on connect how to raise with Friendly message

Post by Daniel Fagnan » Fri 18 May 2007 15:09

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.

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Sat 19 May 2007 11:24

Just catch the exception on the myconnection onerror event handler.
See the faq for more details.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 21 May 2007 07:59

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;

oldmanus
Posts: 1
Joined: Thu 16 Nov 2006 15:59

OnError event handler - abort?

Post by oldmanus » Mon 21 May 2007 17:39

retry, retry, retry......
connect abort? disconnect, kill connection? etc.? :?:

please example....

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Re: OnError event handler - abort?

Post by Antaeus » Wed 23 May 2007 09:30

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?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 23 May 2007 13:20

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.

Post Reply