I am a bit of a novice to SQL Server programming. So, forgive me if my question is too silly or easy.
I have an client-server application where the server connects to an SQL Server and does simple DB operations. In a particular test case, after my SQL Server is shut down and restarted when I try to execute an SQL Statement, the SQLExecute function fails. The problem is that the connection handle used to allocate and prepare the statement is invalid. So, I need to reconnect to the server.
Now my question is, how do I determine if the connection handle is valid or not ? That is, is there any API/function which when used can detect whether the connection handle is invalid or not.
I have tried calls to SQLGetConnectAttr and SQLGetInfo passing the connection handle, but these API's still return the correct value even if the handle is invalid.