Dear All Experts
I faced a problem which cannot solve
In C#, I am using SqlParameter to store the input parameter of stored
procedure with their value
Then in stored procedure, we have 2 style
First, run the SQL normal, e.g.
INSERT INTO Table1 (field1, field2, @param1, @param2)
Another is using EXECUTE sp_executesql, e.g.
SET @nvchSQL = N'INSERT INTO Table1(field1, field2, ' + @param1 + ', ' +
@param2 +')'
If the parameter contains single quote, the first one method is no problem,
but error will occur in method two
If I replace the single quote to two single quote, both can run correct, but
the field value in first method will contains two single quote
I dont want to replace the single quote in stored procedure since it is very
developer dependance, if the developer havent' replace the single quote, the
stored procedure maybe failed. And I would like to solve this problem in
programming level, said write a class to solve this problem, and all
developers will use that class no matter the stored procedure in first or
second format
Thanks