如何在VS 2015中调试存储过程? [英] How to debug stored procedure in VS 2015?

查看:1884
本文介绍了如何在VS 2015中调试存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题很多次,我已经阅读了。
我已经在解决方案中检查了我所有项目中的[启用SQL Server调试]。



我的项目:




  • ASP.NET网络应用程序

  • DAL类库。 (DAL使用传统的.dbml来生成SP调用包装器代码。)否OR mapper既不直接在项目中使用ADO.NET。

  • SQL Server 11.0.3153



在调试VS中的C#代码时,我想调试我调用的SP。理想情况下,它应该进入SP,但如果不支持,那么在一个断点上打破SP。



不幸的是它没有。如果我在SP中设置一个断点,它不是一个填充的红色圆圈,而是一个未填充的,这不是一个好兆头。 (我在服务器资源管理器中设置此断点,打开数据连接,并在VS编辑器中打开SP。



我缺少什么?

解决方案

基于我的经验和研究的一般说明。


  1. 以管理员身份运行Visual Studio(在我的例子中是社区版本)(对于我来说,调试VS中的存储过程只能在VS以管理员身份运行时工作)

  2. 转到解决方案资源管理器,右键单击您的项目并转到属性。

  3. 单击Web选项卡,确保选中了SQL Server。保存并关闭。

  4. 单击查看菜单,然后单击SQL Server对象资源管理器。

  5. 在SQL Server对象资源管理器中,展开SQL Server,如果没有看到您的SQL Server,请右键单击SQL Server并添加它。

  6. 右键单击刚刚添加的SQL Server,并确保检查了应用程序调试和允许SQL / CLR调试。

  7. 展开您添加的SQL Server实例,并找到感兴趣的存储过程。

  8. 右键单击该SP,然后单击查看代码。

  9. 在你想要的地方放一个断点。

  10. 运行并享受。

您可能需要执行以下操作,下次您希望在VS关闭VS后调试存储过程,并稍后再打开。


I know this was asked many times, I've read them. I've checked the [Enable SQL Server debugging] in all my projects in the solution.

My projects:

  • ASP.NET web app
  • DAL class library. (The DAL uses a legacy .dbml to generate SP calling wrapper code.) No OR mapper neither direct ADO.NET used in the project.
  • SQL Server 11.0.3153

I would like to debug my called SPs when debugging the C# code in VS. Ideally it should step in to the SP, but if this is not supported, then break in the SP on a set breakpoint.

Unfortunatelly it does neither. If I set a breakpoint in the SP, it is not a filled red circle, instead an unfilled, which is not a good sign. (I am setting this breakpoint in Server Explorer, by opening a data connection, and opening the SP in the VS editor.

What am I missing?

解决方案

General instructions, based on my experience and research.

  1. Run Visual Studio (community version, in my case) as Administrator (for me, debugging a stored proc from VS only works when VS is run as an admin)
  2. Go to the Solution Explorer, right click on your project and go to properties.
  3. Click on the Web tab and make sure that SQL Server is checked. Save and close.
  4. Click on the View menu, then on SQL Server Object Explorer.
  5. In the SQL Server Object Explorer, expand SQL Server and if you don't see your SQL Server, right click on SQL Server and add it.
  6. Right click on the SQL Server that you just added and make sure that both Application Debugging and Allow SQL/CLR Debugging are checked.
  7. Expand your SQL Server instance that you added and find the stored procedure of interest.
  8. Right click that SP and click View Code.
  9. Put a break point where you wish.
  10. Run and enjoy.

You may have to do some of these things next time you wish to debug a stored proc from VS after you close VS and open it up later.

这篇关于如何在VS 2015中调试存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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