A Clever way to troubleshoot StoreProcedure in Visual Studio

If you have a complex SQL storeProcedure that you want to troubleshoot, the chances are you want to find out what values are being passed to the storeprocedure in the first. In a running application, it is hard to find out. On easy way is this which will solve a lot of your problems and possibly headache.

create procedure usp_GetCustomer
param @customer_id int

begin
select customer_name, customer_address from customer_tbl where customer_id = @customer_id

end

Now lets say you are using this storeprocedure in your gridview and you are getting no result, i.e, the gridview does not populate. An easy way to see what is going on is modify the query to this

select  @customer_id as customer_name, customer_address from customer_tbl where customer_id = @customer_id

Now the first field name “customer_name” will spit out the parameter that was passed  to the stored procedure. This way you will know exactly what is going wrong in your stored procedure.  I hope it helps.

Thanks!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s