Ping method in TMSConnection - example of use.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
akm
Posts: 13
Joined: Mon 16 Apr 2007 01:01
Contact:

Ping method in TMSConnection - example of use.

Post by akm » Tue 24 Dec 2013 20:28

Hi
Give me a small example of use newly added Ping method,
because in doc I can only read, that this method was added.

AndreyZ

Re: Ping method in TMSConnection - example of use.

Post by AndreyZ » Wed 25 Dec 2013 07:35

Hello,

You can use the Ping method in the following way:

Code: Select all

MSConnection.Ping;
The Ping method can be used for the following tasks:
- to check availability of the server;
- to avoid automatic disconnection of the client by the server.

akm
Posts: 13
Joined: Mon 16 Apr 2007 01:01
Contact:

Re: Ping method in TMSConnection - example of use.

Post by akm » Wed 25 Dec 2013 08:25

Hm, Ping isn't return any value (void __fastcall Ping(void);)
May be this method fire some events on TMSConnection?

AndreyZ

Re: Ping method in TMSConnection - example of use.

Post by AndreyZ » Wed 25 Dec 2013 08:33

If a server is not available, the Ping method raises an exception (that is actually raised by the used provider, OLEDB or SQL Native Client).

akm
Posts: 13
Joined: Mon 16 Apr 2007 01:01
Contact:

Re: Ping method in TMSConnection - example of use.

Post by akm » Wed 25 Dec 2013 10:48

OK
Is the right way to use Ping() method like in following example?

Code: Select all

try {
     MSConnection->Ping();
}
catch (exception &Exception)
{
    case (Exception)
      switch Exc1:
          DoSomething();
          break;
      switch Exc2:
          DoSomethingElse();
          break;
    end
}

AndreyZ

Re: Ping method in TMSConnection - example of use.

Post by AndreyZ » Wed 25 Dec 2013 13:51

Yes.

Post Reply