Escape character automatically added to strings retrieved from database
Posted on 2010-11-17
I am storing control characters in a table in a SQL Server database. When I try to retrieve the values from the table, an escape character is automatically added to the values.
For example, the following values are stored in my table:
\t, \n, \r, \r\n
When I retrieve the values from the table using the code below they are changed to:
\\t, \\n, \\r, \\r\\n
How do I keep the framework from adding the escape character to an already escaped literal?
SqlCommand cmd = new SqlCommand("column_delimiter_list", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = cmd.ExecuteReader();
list.Add(new Delimiter(reader["name"] + "", reader["value"] + ""));