Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"The breakpoint will not currently be hit..." error when trying to debug a TSQL stored proc called by .NET code

I am getting the error:

"The breakpoint will not currently be hit. Unable to bind SQL breakpoint at this time. Object containing the breakpoint not loaded"

alt text When I did the steps to debug a stored proc called from my .net app?

What should I be checking?

(VS 2005 and SQL Server 2005 both running on the same PC, I can debug a stored proc if I do "step into" from the Server Explorer)

like image 558
Ian Ringrose Avatar asked Jan 19 '11 15:01

Ian Ringrose


People also ask

How debug SQL stored procedure when called from C#?

Start by going to the Server Explorer and expand the Northwind database node. Next, drill down into the Stored Procedures folder, right-click on the Products_SelectByCategoryID stored procedure, and choose the Step Into Stored Procedure option from the context menu. This will start the debugger.

How do I debug a SQL stored procedure?

To debugging SP, go to database->Programmability->Stored Procedures-> right click the procedure you want to debug->select Debug Procedure.


2 Answers

Make sure that in the project properties > Debug > 'Enable SQL server debugging' checked otherwise you won't be able to step into a stored procedure from your .net code (even though you can step through it using server explorer). Has to be the executing project.

If you're calling the stored procedure from a SqlCommand, set a break point on the Command.Execute() line and then step into it. From there you will be taken to the stored procedure code and will be able to walk through it.

If you continue to get the empty breakpoint icon, try refreshing server explorer.

like image 86
Dustin Davis Avatar answered Oct 06 '22 00:10

Dustin Davis


In addition to enabling SQL Debugging on the project, like DustinDavis said, I had to select "Allow SQL/CLR Debugging" in the context menu for the server in SQL Server Object Explorer (Visual Studio 2015). See How can I step into a SQL Server stored proc from my C# code?

Also make sure both the user account under which VS runs and under which your application connects have sysadmin privileges.

like image 39
EM0 Avatar answered Oct 06 '22 00:10

EM0