Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When did the app connected to SQL Server?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01563233
Message ID:
01563457
Views:
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?

No, just before the first one.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform