[英]How can I step into a SQL Server stored proc from my C# code?
I am debugging some C# code that uses Ado.net to call a stored proc (TSQL) in SQL Server. 我正在调试一些使用Ado.net在SQL Server中调用存储过程(TSQL)的C#代码。 How can I step into the stored proc? 我怎样才能进入存储过程?
(I think I have seen this demoed by Microsoft staff, but can't recall the 101 “magic” settings that are needed to get it to work.) (我想我已经看过微软工作人员演示的这个,但是不记得让它工作所需的101个“神奇”设置。)
I'll build on Davide's answer and Ian's comment to it because that was the exactly the process I have gone through. 我将以Davide的回答和Ian对它的评论为基础,因为这正是我经历的过程。
Assumption : answer is based on VS2008 & VS2010 . 假设 :答案基于VS2008和VS2010 。
To step through a T-SQL stored procedure on SQL Server while debugging a .NET app you need to do the following: 要在调试.NET应用程序时在SQL Server上单步执行T-SQL存储过程,您需要执行以下操作:
Follow the MS Support instructions " How to debug stored procedures in Visual Studio .NET (Option 2) " 按照MS支持说明“ 如何在Visual Studio .NET中调试存储过程 (选项2) ”
Enable the Allow SQL/CLR Debugging on the Data Connection on which the stored procedure is called: 在调用存储过程的数据连接上启用“ 允许SQL / CLR调试 ”:
Added from comments: (This seem to be key to getting it to work) 从评论中添加:(这似乎是让它工作的关键)
It works with a programmatically created connection, too. 它也适用于以编程方式创建的连接。 You just have to use the exact same connection string that is displayed when you right-click the server instance, click on 'Properties' and scroll down to 'Connection string' (Verbindungszeichenfolge in German). 您只需使用右键单击服务器实例时显示的完全相同的连接字符串 ,单击“属性”并向下滚动到“连接字符串”(德语中的Verbindungszeichenfolge)。
For those of you who are using VS 2012 and are confused as to why you cannot enable SQL/CLR Debugging from the Server Explorer window, you actually need to connect via the "SQL Server Object Explorer" window. 对于那些使用VS 2012并且对于为什么无法从“服务器资源管理器”窗口启用SQL / CLR调试感到困惑的人,实际上需要通过“SQL Server对象资源管理器”窗口进行连接。
Once you have the connection in that window, the Allow SQL/CLR Debugging
and Application Debugging
setting appear on the right-click context menu of your server. 在该窗口中建立连接后,将在服务器的右键单击上下文菜单中显示“ Allow SQL/CLR Debugging
和Application Debugging
设置。 This probably applies to 2013 as well but I cannot confirm. 这可能也适用于2013年,但我无法确认。
在项目属性中启用SQL Server调试。
In Solution Explorer, right-click the project (not the solution) and open the Property pages. 在解决方案资源管理器中,右键单击项目(而不是解决方案)并打开“属性”页面。 Click Configuration Properties in the tree and then click to select the SQL Server Debugging check box on the Debugging page to enable stored procedure debugging. 单击树中的“配置属性”,然后单击以选中“调试”页面上的“SQL Server调试”复选框以启用存储过程调试。
reference: http://support.microsoft.com/kb/316549 参考: http : //support.microsoft.com/kb/316549
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.