7wp
7wp

Reputation: 12694

How to Inspect ODBC communication, to see the SQL being passed through?

Is there a tool for windows that we can use to inspect any SQL commands that go through a particular ODBC data source?

Upvotes: 2

Views: 781

Answers (2)

Tim Sylvester
Tim Sylvester

Reputation: 23148

You can make ODBC log out everything it's doing:

When you start tracing from the Tracing tab, the Driver Manager will log all ODBC function calls for all subsequently run applications. ODBC function calls from applications that are running before tracing is started are not logged.

  • If it is necessary, log on using an account that has membership in the Local Administrators' group.
  • From Administrative Tools, open the ODBC Data Source Administrator.
  • Click the Tracing tab.
  • Configure the tracing mode using the Machine-Wide tracing for all user identities check box:
  • To enable machine-wide tracing, select the check box.
  • To return to per-user tracing, clear the check box.
  • Click Apply.

http://msdn.microsoft.com/en-us/library/ms711020%28VS.85%29.aspx

Note that:

When you start tracing from the Tracing tab, the Driver Manager will log all ODBC function calls for all subsequently run applications. ODBC function calls from applications that are running before tracing is started are not logged.

You can also do it programmatically:

... One can do this by calling SQLSetConnectAttr and set the SQL_ATTR_TRACE attribute in the connection to SQL_OPT_TRACE_ON. So, by doing this you would be enabling/disabling it for the connection duration.

http://decipherinfosys.wordpress.com/2009/01/17/odbc-tracing/

Upvotes: 5

3Dave
3Dave

Reputation: 29051

If you're using SQL Server, look at the SQL Server Profiler. Profiler allows you to monitor/trace all communications between your application and the SQL Server, including which procedures are called, parameter values, etc, without having to modify your application.

If you're using a different server, you should be able to find a sql proxy that will do the same thing.

Upvotes: 0

Related Questions