Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unaccountable Fake-Error from Sql Server
Message
 
 
To
11/06/2004 04:41:34
Emanuele Bonin
EB Soluzioni Informatiche
Tezze S/B, Italy
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00912576
Message ID:
00912754
Views:
9
I have posted this before but...

I usually do something like the following if a driver seems apt to error unaccountably like this. It seems a little wasteful to do this all the time, but it works and it is transparent.

This is a bit cut-down, forgive me if there is an IF/ENDIF somewhere, you'll get the idea.

There are a number of possible reasons it happens, btw. With some drivers it can even be a licensing errors, with at least one it can be a memory leak.
IF THIS.HasValidDataSources()...

   * do the work

ENDIF

PROTECTED PROCEDURE HasValidDataSources

  IF THIS.ValidDataSources
     LOCAL lFailure, cConnect, dummy
     IF ATC("'SKIP_XXX'",THIS.XXXConnectionString) = 0
        * try a dummy query that doesn't
        * "cost" too much
        dummy = SQLGETPROP(THIS.XXXHandle,'ConnectTimeout')
        lFailure = (ATC(TRANSFORM(VFPERROR_CONNECTION_HANDLE_INVALID),;
            THIS.ErrorMessage) > 0) OR ;
            ("connectivity"  $ LOWER(MESSAGE()))
                       
        IF lFailure
           * attempt to get rid of driver resource problem
           * now disconnect; the extra error won't hurt
           SQLDISCONNECT(THIS.XXXHandle)
      
           THIS.ClearError()
           * try a reconnect
           cConnect = THIS.XXXConnectionString
           THIS.XXXHandle = SQLCONNECT(&cConnect)
           lFailure = (THIS.XXXHandle < 1)            
        ENDIF
     ENDIF
     IF NOT lFailure AND  ;
         ATC("'SKIP_YYY'",THIS.YYYConnectionString) = 0
     * do the same thing for the
     * next datasource
     ENDIF
     IF lFailure 
        THIS.ValidDataSources = .F.
     ENDIF
  ENDIF   
  RETURN THIS.ValidDataSources
ENDPROC
Previous
Reply
Map
View

Click here to load this message in the networking platform