Re: How to get ODBC the status of connection?

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Tue, 07 Aug 2007 00:09:17 -0700, Hooyoo <zhaohuyong@xxxxxxxxx>
wrote:

How can I get the status from the handle of connection? I have
initialized a connection at the beginning, but I need know whether the
connection is still established when I execute a sql statement. Is
there such kind of ODBC API?

For ODBC ver. 3.5, you can call SQLGetConnectAttr() with the argument
SQL_ATTR_CONNECTION_DEAD (see the "ODBC Programmer's Reference" for
details on how to call this function). I'm not aware of how this is
done in earlier ODBC versions; presumably you would just trap the
error which occurs when the SQL statement is prepared or executed.

If the handle itself is invalid, the call to SQLGetConnectAttr
returns SQL_INVALID_HANDLE.

--
Bob Hairgrove
NoSpamPlease@xxxxxxxx
.



Relevant Pages