by Jeff Luther » 11 Mar 2008, 17:44
Posted by: Jeff Luther
The issue is that TD is catching this error, not the DB, so there's no
'sql error.' (it's a TD runtime error.)
TD is catching this because it's doing a lookup in its struct of sql
handles and finds that hSql is invalid, or as in the case of the jpg
I've attached, SqlDisconnect() sets hSql = 0 and TD catches it as a 0
handle. (A Sql Handle is a complex struct; TD just uses the var. Sql
Handle as a simple number, which is then an offset into this array of
structs of all handles connected. First hSql = 1h, 2nd = 2h, etc.)
"... [at] the very least give a sensible error message [for an invalid
handle]" - Well you can, yes and no. Yes, because it can be done to
catch your hSql handles before a call , but no, because I don't see it
can be done without some changes to your code.
"I was hoping that there was some way to catch the invalid cursor error
in code" - To catch the error yourself, you would have to add some code.
1 - as Jim says, use: "If hSql = hWndNULL" or "!=" before any/all of
your Sql calls and do error handling in a function, say;
2 - or write a function that all your Sql commands go through and eval.
the handle passed before it gets used in a Sqlxxx() call.
You just can't do that extra error handling without adding some code,
because it's a coding and/or logic error, not a backend/db/sql error.
Alternatively--and likely fewer places--add a little code before/after
each of your SqlDisconnect() calls? Since you think B or C is the
problem, the code could alert when a disconnect was being done too early.
Jeff @ PC Design
info. & samples: www.JeffLuther.net/unify/
You do not have the required permissions to view the files attached to this post.