Add parameter value that contains a single quote (C#)

May 23 2005 11:06 AM
I am trying to set a value to a parameter for an OracleCommand object. The SQL statement selects based on the value or set of values contained in the string, e.g. "WHERE work_schedule IN ('CJ','CL','CP')". If I set the value to a string that does not contain a single quote, the query works and I get the expected results. If I pass it a string that contains a single quote, it returns ORA-01403 (no rows found). I have tried preceding each single quote with another single quote, preceding each single quote with a backslash, and trying each of these syntaxes AND preceding the entire string with '@', which according to .net documentation, forces .net to read the string 'verbatim'. NONE of these syntaxes work. I have used parameterized queries in C for years. I am new to C# and .net. There MUST be a way to create and execute a query which searches for multiple values in C#!! I can't believe there isn't. Does anyone know how to do this?? Thanks

Answers (2)