Click here to Skip to main content
15,897,187 members
Articles / Web Development / ASP.NET
Tip/Trick

Way to Debug SQL Parameters in ASP.NET

Rate me:
Please Sign up or sign in to vote.
1.00/5 (2 votes)
18 Feb 2010CPOL 14.3K   2   2
While using stored procedures, we need to pass SQL parameteres to those stored procedures. When there are large numbers of parameters then it is become boring task or tedious job to debug and check what values passed with. Here I have created a function that will check the values passed to...
While using stored procedures, we need to pass SQL parameteres to those stored procedures. When there are large numbers of parameters then it is become boring task or tedious job to debug and check what values passed with.

Here I have created a function that will check the values passed to the Stored procedures.

Just pass SQL command to to this function.

When you are writing stored procedures you may need to send parameters to SQL. Use below function to check, what are the values are passed to debug your code.

Paste it in App_code folder and just pass the SQL command with parameter.
VB
Public void SPValues(SqlCommand sqlCmd)
{
string myStr1=String.Empty;
string myStr2=String.Empty;
SqlParameter prm;
foreach(prm in sqlCmd.Parameters)
{
myStr1 += "'" + param.Value + "',";
smyStr2 += "<br>" + param.ParameterName & "=" + param.Value;
System.Web.HttpContext.Current.Response.Write("EXEC " + SQLCMD.CommandText + " " + myStr1);
System.Web.HttpContext.Current.Response.Write(myStr1);
}
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior) Excel Informatics, Pune
India India
Am Indrajeet T. Sutar. I am a web developer. I am working on .net technology. I have completed my Masters in Computers and Management (people call it as MCA, MBA etc.) Apart from programming i do photography (not regularly though), traveling and reading books.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Peter Howard25-Nov-12 19:04
Peter Howard25-Nov-12 19:04 
QuestionA simple question? Pin
Md. Marufuzzaman20-Feb-10 6:54
professionalMd. Marufuzzaman20-Feb-10 6:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.