Scenario
I am executing a stored procedure using ADO.NET SqlCommand:
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_Trk_GetSuspiciusVisitor";
cmd.Parameters.Add(new SqlParameter("channel","gb"));
cmd.Parameters.Add(new SqlParameter("data", DateTime.Today.AddDays(-1)));
cmd.Connection = conn;
I would like to log the executed sql statement. In this case I would like to log the string:
sp_Trk_GetSuspiciusVisitor 'gb', '2012-08-12'
Question
Is there any property of the SqlCommand or of the SqlConnection classes that does the job?
no, unfortunatelly you would have to loop through all the paramenters to get their values and concatenate it with the command text