Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Practical uses for SQLIDLEDISCONNECT()
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01684846
Message ID:
01684884
Views:
46
>>>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...
>
>I do something very close to this. Really the problem he has is not to hard to fix - I have done it before.
>
>1. Create a function called saferequery - it will take parameter of view to use.
>2. Put code like what you have above in the new function along with the actual requery command to requery the view name passed in the paramater.
>3. Use goFish to change all the places in your app where you say requery() to saferequery() -- (be careful its requery for views and not controls).
>
>Really the whole processes should take him 15 minutes to fix all of it.

Yes!

The Code above was a conclusion.
In our Application it is located in our Datahandler Class where every SPT Query, or Remote View Operation goes through. (Our Application can be switched from DBF to SQL). So the Modification, once the Solution was found, was relatively easy.
Jörg Schneider
Joerg.Schneider@SMARTCRM.de
SMARTCRM CRM powered by MS Visual FoxPro
SMARTCRM GmbH
Previous
Reply
Map
View

Click here to load this message in the networking platform