Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
When did the app connected to SQL Server?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01563233
Message ID:
01563452
Vues:
50
>>>>Hi,
>>>>
>>>>Say you are using CursorAdapter for getting and setting data in SQL Server. Do you know if the actual connection to the SQL server occurs when the application calls CursorFill() method of the CursorAdapter?
>>>>
>>>>And by the same token, when updating the SQL Server database, does the connection to SQL Server happens when the TableUpdate() is called?
>>>>
>>>>TIA
>>>
>>>You must have opened connection in in order to call CursorFill(), no matter what is used ADO or ODBC.
>>>The connection should stay opened during the lifetime of the CA.
>>
>>You are right. But I should have phrased my question better (in the title). I am trying to determine when the connection to the SQL Server was used last time. And if I understand correctly the call to CursorFill() is when the application actually used the connection. My goal is to "stamp" this time and check for it next time the application uses the connection. If the time since the last connection use is greater than the ConnectionTimeOut I want the application to check if the connection is still valid. If not, create a new connection.
>
>You can't measure this.
>This depends of the user. The use can open a form (CursorFill() is executed) Then goes to drink coffee or close the form w/o updating anything in the Cursor. Then there will be no TABLEUPDATE().
>So, better check connection before executing TABLEUPDATE(). I usually do something like this (ODBC):
>
>IF SQLEXEC(lnConnection, "SELECT CAST(1 as bit) As Test", "crsTestConnection")  < 0
>   *** The connection is NOT valid
>ENDIF
>
I appreciate your explanation. But reality in my application most (if not all) problems with connection I get are on SQL Select. For example, when the appliction creates BIZ object(s), and empy cursor for CA is first created. That is the CA has no records. So typical SQL Selects would like following:
Select TableName.Field1, TableName.Field2, TableNameField3 from TableName where 1=0
And quite often the error on the above is
[Microsoft][ODBC SQL Server Driver]Communication link failure
Do you suggest to execute SQLEXEC() as the example you shown above before Instantiating each CA object?
"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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform