I had to dynamically create Sql statements for the parameters of a stored procedure due to the legacy database access layer.
var p1 = Encoding.ASCII.GetString(p1).Replace("'", "''").Replace("\n", " ");
var p2 = Encoding.ASCII.GetString(p2).Replace("'", "''").Replace("\n", " ");
.....
var sql = string.Format("exec storedprocedure @p1='{0}', @p2='{1}', @p3='{2}', ....",
p1, p2, p3, ...);
Right now I replace ' to '' and \n' to an empty space after converting the strings to ascii string. What else I need to do? I cannot use SqlParamter and had to concat the string due to some facts.
\', ",\", unicode that when decoded in the right way turns into one of the above ( security.stackexchange.com/questions/11391/… ), etc?