Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check whether a connection still exists?
Message
 
 
To
09/01/2004 21:17:49
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00865357
Message ID:
00865989
Views:
20
After the error, I do something like the following. The point is, I really only need to check for one error, not all of them, no matter what occurred previously.

Actually I do this at other times even when there isn't an error, if I have reason to be believe that something external may have killed the connection. The code you see here talks to an AS400 driver that periodically dies for lack of resources on the server, nothing I can control.

I don't think you need to see the object's error method here; take it as read that there is one, and THIS.ErrorMessage has what I need in it <s>. I also check MESSAGE() but probably don't need to.

>L<
            LOCAL dummy, lFailure

            dummy = SQLGETPROP(THIS.S2SHandle,'ConnectTimeout')

            lFailure = (ATC(TRANSFORM(VFPERROR_CONNECTION_HANDLE_INVALID),;
                        THIS.ErrorMessage) > 0) OR ;
                        ("connectivity"  $ LOWER(MESSAGE()))
                        
            IF lFailure

               * now disconnect; the extra error won't hurt
               SQLDISCONNECT(THIS.S2SHandle)
      
               THIS.ClearError()

               * try a reconnect
               cConnect = THIS.S2SConnectionString
               THIS.S2SHandle = SQLCONNECT(&cConnect)
               lFailure = (THIS.S2SHandle < 1)            

               * Re-setup anything else required when a 
               * connection is initialized here... 

            ENDIF

            * now IF lFailure, I have a fatal error.
Previous
Reply
Map
View

Click here to load this message in the networking platform