Re: Lost connection



"Shaolin" <milos.klvan@xxxxxxxxx> wrote in message news:46836c49@xxxxxxxxxxxxxxxxxxxxxxxxx

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).

It doesn't. Not than anyway...

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.

Ping still can help here, since you obviously know the server you're connected to. Pinging
the server could be run seperately in another thread and a flag could be set indicating
the status at last ping time.
But ADO only raises an exception when it actually uses the connection, as you found out.
It still raises an exception though, so somehow you are going to have to catch that, or
your application crashes.


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

If not, this means every query has its own - possibly implicit - connection. As Yannis
pointed out in another mail, it is best to have only one TADOConnection object per
application (actually, per thread). That would make life much easier...
I'm hoping this is not the case with your application.


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

What is the difference between determining connection status before each and every of
those 30000 queries, or handling the exceptions that can occur with each of those 30000
queries? If you don't have a single point of entry (TADOConnection) in either case you
have to change your source for every query. And, since ADO (the Delphi implementation
anyway) raises exceptions in cases of network errors, you still would have to handle those
exceptions.
One difficulty with exception handlers would be re-executing the query whenever a network
error occured. Unlike Visual Basic, which had a nice On Error Resume statement, you can't
simply jump back into the code executing the same query again from the exception handler.
But that can be resolved...

If you really have 30000 query objects (TADOQuery, whatever) sprinkled around in your
code, you have a real maintainance nightmare. No matter which way you would tackle the
disconnection detection, you would have to repeat it for all of those queries. That's a
tough job....

....Arjan...


.


Quantcast