Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Way to Debug SQL Parameters in ASP.NET

0.00/5 (No votes)
18 Feb 2010 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here