Re: Lost connection



On Jun 28, 12:55 pm, "Shaolin" <milos.kl...@xxxxxxxxx> wrote:
Hm. ADO does not recognize the disconnection from the database until it
tries to talk to
it - when executing queries, for example. Not sure if there are any

special functions to

call in order to detect the disconnect.
One way of detecting it would be to 'ping' the IP address (assuming you
can reach the
server by TCP/IP) and set a flag if the server does not respond in time.

The network can be OK again at the moment I want to execute query. But if
there was for example 30 second network problem before then it will raise
an exception. I can evoke it in this way:
My application is doing nothing and is waiting. ADO is connected. Then I
pull out a network cable from my computer for 30 seconds. At this moment
ADO is still conected (let us say it doesn't recognize the disconnection).
Then I click the button to execute query and an exception will be raised.
That's why 'ping' will not help me. We use DHCP so IP adress can be changed.



But why refrain from using exceptions? This sort of situations are what
try...except
blocks are designed for.
In the last data access layer I wrote I too needed to cater for losing
connections due to
mobile Windows Embedded stations which could move out of the wireless
network range for
short periods. I resolved it nicely using exception handling. The
applications just
execute queries and when the connection has been lost, in the background
there are several
attempts made to reconnect - all without the front end even knowing. It
only takes longer
to get the data or possible receive an error that the database can't be
reached now. When
they move within network range, all the operators need to do is refresh
or refire the
query they were trying to execute and the connection is reestablished.
Works like a
charm - and with exception handling....

Our application has about 1000 units in different modules and about 30000
queris, therefore is not possible to handle every query.

First thing I need is detect that this problem occurs. Then I can handle it.

Thank you for your time Arjan.

Milos

--- posted by geoForum onhttp://delphi.newswhat.com

1- onwillexecute event can overcome ur problem, and you dont need to
check intervally the connection but you can check the connectivity on
the first connection needed, after disconection you can check the
connection intervally by pinging the server by its name

2- ur data server must have an static ip address, dhcp is not the safe
job

GOOD LUCK

.


Quantcast