调试“不正确的语法”例外
我最近一直在使用 COM+ 组件,该组件处理输入 XML 文件,并根据提供的数据进行大量数据库更新。
使用 EventClass 异常运行 SQL Profiler,并选择用户错误消息,我看到:
异常错误:102,严重性:15,状态:1
用户错误消息“3”附近的语法不正确。
不过,我确实想查看 COM+ 组件提供的完整 SQL。
我是否可以使用 Profiler 或其他工具来拦截发送到 SQL Server 的 SQL 语句?
本机使用的是SQL Server 2005,COM+对象是用Delphi编写的。
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 supplied 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Profiler 中,尝试观察事件 SP:StmtStarting 和 SQL:StmtStarting,并在输出中包含 TextData 列。
我认为,如果您选择“事件选择”选项卡上的“显示所有事件”复选框,这些事件只会显示在选择列表中。
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.
所需的事件是 SQL:BatchStarting 或 SQL:BatchCompleted。主要的令人困惑的一点是 SQL 是在错误消息之后输出的 - 当您考虑它时,这确实有意义,但可能不直观。
例如,通过查询 SELECT * FROM Table WHERE ID=3 8(注意 3 和 8 之间的空格不正确),我收到了以下输出。
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.