Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Practical uses for SQLIDLEDISCONNECT()
Message
From
24/08/2022 10:58:34
 
 
To
23/08/2022 14:24:38
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01684846
Message ID:
01684874
Views:
67
Likes (1)
>Hi. I have a problem with remote users randomly losing their VPN connections to a SQL Server database, (by the way, I use remote views on all my apps).
>
>I was searching the VFP Help but didn't find any function or command that would help me avoid the errors and allow me reconnect the view somehow within the app.
>
>While I was searching the help file I found the SQLIDLEDISCONNECT() function, which I don't get how that could be used. Perhaps to solve my proble? But I don't see how. Any help would be much appreciated.
>
>TIA

Hi Luis!

We have had over the years some Errors like 'Communication Link failure' aso.
Since we have implemented extended error handling, there are no more errors...
I try to compact our solution because it is implemented in our Framework.

In Words:
You can check database Connection very easy by sending a empty string via sqlexec(). If the Connection is still alive every thing is ok.
If not you have to check the Error array. If connection error occurs, you can try to make the Connections IDLE (with the function you've already found). and then you can try again to reconnect.
...
* test SQL Connection
if sqlexec(lnConnectionHandle, []) >=0
  * Everything is fine
else
  * now check aError
  aerror(laError)
  if m.laError[1,1] = 1526
     * It is an SQL Connection error, now a look at the 5. Column can give us Details
     do case
          case  laError[1,5] = 229
              * Connection error!
              * Now first you have do make all sql Handles idle
               asqlhandles(laSqlhndls)
               for each m.lnOdbchdbc IN m.laSqlhndls foxobject 
                     sqlIdleDisconnect(m.lnOdbchdbc)
               endfor

              * And now, try again to check the SQL Connection
               if sqlexec(lnConnectionHandle, []) >=0
                 * Everything is fine
               else
                 * now check aError again.... --> Ok, you have to put everything in a Loop, an we show the User a Message "Connetion is broken, wait until it workes again"... aso.
          case inlist(laError[1,5], 1205, 1222) 
              * Deadlock or Lock occured, you have to Deal with it...
    endcase
  endif
endif
This also works with remoteviews. You only have to place your connectionCheck Code before requery/use RemoteView...
Hope this Code Snipp helps you...
Jörg Schneider
Joerg.Schneider@SMARTCRM.de
SMARTCRM CRM powered by MS Visual FoxPro
SMARTCRM GmbH
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform