I've done this before, to debug parameters.
It totally depends on the way you are passing in parameters. I was using the SqlParameterCollection, and then did a foreach on each parameter.
Code:
string SqlDebug(string storedProc, SqlParameterCollection params)
{
StringBuilder text = new StringBuilder();
text.AppendFormat("Calling {0} with {1} params: ",storedProc,params.Count);
if(params.Count ==0)
return;
foreach(SqlParameter singleParam in params)
{
text.AppendFormat("{0} = {1},"singleParam.Name, singleParam.Value.ToString());
}
//Remove last comma
text = text.Remove(text.Length-1,1);
return text.ToString();
}
Hope this helps,
Dom