开发者

Debugging "Incorrect Syntax" Exception

开发者 https://www.devze.com 2022-12-30 05:14 出处:网络
I have recently been working with a COM+ component that processes an input XML file, and makes a number of database updates based on the suppli开发者_开发问答ed data.

I have recently been working with a COM+ component that processes an input XML file, and makes a number of database updates based on the suppli开发者_开发问答ed data.

Running SQL Profiler with EventClass Exception, and User Error Message selected, I see:

Exception Error: 102, Severity: 15, State: 1

User Error Message Incorrect syntax near '3'.

However I really want to see the full SQL that is being supplied by the COM+ component.

Is there anyway for me using Profiler, or other, for me to intercept the SQL statement that was sent to the SQL Server?

This machine is using SQL Server 2005, and the COM+ object is written in Delphi.


In Profiler, try watching the events SP:StmtStarting and SQL:StmtStarting, and include column TextData in the output.

I think those events are only shown in the pick list if you select the "Show All Events" checkbox on the Events Selection tab.


The events needed are SQL:BatchStarting or SQL:BatchCompleted. The main confusing point is that the SQL is output AFTER the error messages - which does make sense when you think about it, but may not be intuitive.

As an example, with the query SELECT * FROM Table WHERE ID=3 8 (note the incorrect space between 3 and 8), I received the following output.

Exception   Error: 102, Severity: 15, State: 1
User Error Message  Incorrect syntax near '8'.
SQL:BatchStarting   SELECT * FROM Table WHERE ID=3 8
SQL:BatchCompleted  SELECT * FROM Table WHERE ID=3 8
0

精彩评论

暂无评论...
验证码 换一张
取 消