An Idea can change your life.....

Thursday, February 21, 2008

Debugging Stored Procedures in Visual Studio 2005

Follow the step's mentioned below


1.The first thing you want to do is add a data connection in the Visual Studio 2005 Servers windows. Right click on "Data Connections" and click on "Add New Connection":




2.Enter the required connection info in the "Add Connection" dialog and click "Test Connection" to test the connection. If that succeeds, click OK:



3.After you add the data connection you will be able to see the connection in the Data Connections tree:
We're going to debug "uspgetbillofmaterials" in this example (any proc will do, it really doesn't matter what proc YOU use). Drill down until you can see the proc you're debugging under the "Stored Procedures" folder:



4.Right click on the proc and click "Open". You will see the proc code in the code window:



"Now we debug"

5.Now that we've figured out how to open the proc we're going to get into actually debugging it. Right click on the proc and click "Step Into Stored Procedure":




6.A window with all of the parameters for the proc will pop up:




Notice it says "The stored procedure ... REQUIRES the following parameters:" That means you are REQUIRED to fill in the values. Otherwise the debugger will quit right away. That said; click the OK button to step into the procedure. The debugger will automatically stop execution on the first line of code in the stored procedure. When the debugger has stopped execution you'll see a yellow arrow to the left of the line of code:



7.Depending on how you have your Visual Studio settings you will click either F8 (VB) or F11(C#) to go to the next line of code. The debugger will execute the previous line of code and move to the next line

No comments: