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.)
Using SQL Server Management Studio Expand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure and then select Script Stored Procedure as, and then select one of the following: Create To, Alter To, or Drop and Create To.
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.
To debugging SP, go to database->Programmability->Stored Procedures-> right click the procedure you want to debug->select Debug Procedure.
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:
Follow the MS Support instructions "How to debug stored procedures in Visual Studio .NET (Option 2)"
Enable the Allow SQL/CLR Debugging on the Data Connection on which the stored procedure is called:
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With