On 9/25/2013 3:19 PM, Mike Copeland wrote:
There are probably better ways to do it, but I use

     nResult=SQLEXEC(datahandle,'SELECT @@identity')

If nResult is 0 then I just assume that there is a problem and proceed
to disconnect, throw away the old handle, and then reconnect. If that
fails, then bail out.  "Select @@identity" has a very low footprint,
returning nothing and only useful to see if the communication link is
still valid (as far as I know.)

Some Fox error codes to look for would be 1526, 1466, and 2006.

I've never used views, but in my opinion using views with SQL is not
recommended. I just fetch whatever data I need from the server and the
connection is only needed for that data transmission. After that brief
communication, nothing is assumed and the next communication has to
stand on its own. I run the above "Select @@identity" before each
request for data. Yeah, additional overhead, but it's quick and ensures
that the connection is still valid.


This is what I do too, but I don't use Views for the same reason. I use SPT cursors and when it's time to update, I test the current connection in a similar way to what Mike said and if invalid I reconnect. Works great since 2004!


--
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
http://fabmate.com
http://twitter.com/mbabcock16

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to