Monday, June 27, 2011
Tracing Calls to Stored Procedures from C
//where cmd is of type SqlCommand
Console.WriteLine("");
Console.WriteLine(cmd.CommandText);
String sep = " ";
foreach (SqlParameter param in cmd.Parameters)
{
if (param.SqlValue.Equals("Null"))
{
Console.WriteLine(sep + param.ParameterName + "=" + param.SqlValue);
}
else
{
switch (param.SqlDbType)
{
case SqlDbType.NChar:
case SqlDbType.NVarChar:
case SqlDbType.VarChar:
case SqlDbType.Char:
case SqlDbType.Date:
case SqlDbType.DateTime:
case SqlDbType.DateTime2:
case SqlDbType.SmallDateTime:
case SqlDbType.Text:
Console.WriteLine(sep + param.ParameterName + "='" + param.SqlValue + "'");
break;
default:
Console.WriteLine(sep + param.ParameterName + "=" + param.SqlValue);
break;
}
}
sep = ", ";
}
Console.WriteLine("");
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment