Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplicate losing SQL Connection
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Duplicate losing SQL Connection
Miscellaneous
Thread ID:
01658232
Message ID:
01658232
Views:
39
Hi,

I am trying to duplicate a case where the connection to SQL Server is lost. Using Cursor Adapter to update table(s).

Here is what prompted me to look into this.

I sometimes get a message from customers where the error message is "Communication Link Failure." The program usually records - at the time of the error - the value of global SQL Connection Handle and the value of the CA Cursor Connection Handle (that the the value assigned to the CA object when it is created). I noticed that they are different at the time of the error. For example, the Global SQL Conn Handle is 2 and the CA Cursor Conn Handle is 1. I know how this happens. The application periodically checks if the current Global SQL Conn Handle is valid (by executing a very simple SQL Select). If the handle is not valid, the application connect again and gets a new Global SQL Conn Handle. This is the case above; the app had Global Conn Handle 1; the user was idle for a while; connection lost; the application connected again and the new Global Conn Handle is 2. But the cursor adapter object still has the value set to the initial Global Conn Handle, 1. And therefore at the time of the TableUpdate(), run time error.

My test of hard-coded change of the Global Conn Handle didn't duplicate the problem. Because the initial handle is still valid even though I change the value in the VFP application.

My question is, should I create a loop of all currently open CA cursors and update their SQL Conn Handle if the Global Conn Handle has been updated?

Or, how can I test/duplicate this condition?

TIA

UPDATE: I figured how to duplicate the problem. I can use SQLDISCONNECT(nOldBadHandle). And this generates an error on TableUpdate().
Then, I tested a case of dynamically updating the CA object SQL Handle with the new value. And it works! That is, the CA object only "cares" if the SQL Server handle is valid and not that is has to be equal to the value when the object was created.
Therefore, this should resolve my problem. Which has been a nagging problem for a while.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Next
Reply
Map
View

Click here to load this message in the networking platform