我如何从我的C#代码进入SQL Server存储proc? [英] How can I step into a SQL Server stored proc from my C# code?

查看:92
本文介绍了我如何从我的C#代码进入SQL Server存储proc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调试一些使用Ado.net的C#代码来调用SQL Server中的存储过程(TSQL)。我如何进入存储过程?



(我认为我已经看到这个由Microsoft工作人员演示,但不记得所需的101魔术设置为了让它工作。)

解决方案

我将建立在Davide的答案和Ian对它的评论,因为那是



假设:答案基于 VS2008& VS2010



要调试.NET应用程序时,要跨SQL Server上的T-SQL存储过程,您需要执行以下操作:


  1. 按照MS支持说明 如何在Visual Studio .NET中调试存储过程(选项2)




    • 确保您已在项目的属性(链接说明中的步骤4)中启用了 SQL Server调试

    • 确保您已经设置了断点存储过程本身(步骤6-7)


  2. 启用允许SQL / CLR调试在存储过程调用的数据连接上:




    • (没有第二步,你会得到 断点当前不会受到打击,此时无法绑定SQL breakponit。包含断点未加载的对象

    • 服务器资源管理器>数据连接

    • 右键单击在您在代码中使用的连接上

    • 勾选菜单中的允许SQL / CLR调试选项







从评论中添加:(这似乎是获取它的关键工作)



它与编程创建的连接一起工作。您只需使用右键单击服务器实例时显示的完全相同的连接字符串,单击属性,然后向下滚动到连接字符串(Verbindungszeichenfolge in German)。 p>

I am debugging some C# code that uses Ado.net to call a stored proc (TSQL) in SQL Server. 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.)

解决方案

I'll build on Davide's answer and Ian's comment to it because that was the exactly the process I have gone through.

Assumption: answer is based on VS2008 & VS2010.

To step through a T-SQL stored procedure on SQL Server while debugging a .NET app you need to do the following:

  1. Follow the MS Support instructions "How to debug stored procedures in Visual Studio .NET (Option 2)"

    • Ensure that you have enabled SQL Server debugging in the project's properties (Step 4 in the linked instructions).
    • Ensure you have set a breakpoint in the stored procedure itself (Steps 6-7)
  2. Enable the Allow SQL/CLR Debugging on the Data Connection on which the stored procedure is called:

    • (without this second step you'll be getting "The breakpoint will not currently be hit. Unable to bind SQL breakponit at this time. Object containing the breakpoint not loaded." as reported by Ian)
    • Server Explorer > Data Connections
    • Right-click on the connection that you are using in the code
    • Tick the Allow SQL/CLR Debugging option in the menu


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).

这篇关于我如何从我的C#代码进入SQL Server存储proc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆