I'm using C++ to query a SQL Server 2005 database using ODBC. The queries contain parameters that I set using SQLSetParam(). I run the queries by calling SQLExecute().
Occasionally a query will fail, and I need to log the context of the failure. I am calling SQLError() to get the error information, but I would also like to log the raw query that the ODBC driver tried to run - that is, the query with the parameter values expanded-out. Can anyone advise if there is a way to get access to this?
The context is error logging in a production environment. I'm not "there" when the error happens, so I can't use the profiler or similar tools. Thats why I want to log as much information as possible for analysis later.