I have following ADO.Net C# code for executing stored procedure with parameters. When I observe the profiler it is listed as
exec uspSecurityGetChildActivitiesByInternalName @ActivityInternalName = N'INVWLVIEWEDIT'
But I want it to be modified as
exec uspSecurityGetChildActivitiesByInternalName @ActivityInternalName = 'INVWLVIEWEDIT'
I need to avoid the N
before parameter value. This should be possible because in the original trace I have, it is coming without N
(though I don’t have the source code for that).
How can we modify the following C# code to create exec
statement in profiler without N
?
REFERENCE
- Can SQL Profiler display return result sets alongside the query?
- Exception when AddWithValue parameter is NULL
Code:
using (SqlCommand command = new SqlCommand(spName, connection))
{
WriteLogFunction(spStatement);
command.CommandType = System.Data.CommandType.StoredProcedure;
if (paramsList.Count > 0)
{
foreach (Parameter p in paramsList)
{
command.Parameters.AddWithValue(p.MyParameterName, p.MyVal);
}
}
string resultVal=String.Empty;
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
resultVal = reader.GetString(0);
}
}
}
//Other code
}