I am having a SQL query of the form:
Update TableName Set TaskStatus=xxx where TaskID=xx;
I have this SQL query in my C# code.
In an excel file, under B cell, I have a set of statements like Rejected, Completed, Closed and so on. My C# code reads those cells and takes appropriate actions. For example, if it reads Completed, then the below query gets executed:
Update TableName Set TaskStatus=Completed where TaskID=xx;
My problem is, in a cell, I am having the value Can't Complete. When my code reads this cell and merges this into the query,
Update TableName Set TaskStatus=Can't Complete where TaskID=xx;
it throws an error stating that "quotes should be closed" It is assuming the quote in Can't as a SQL keyword or SQL quotation. How do I get over this?
Update TableName Set TaskStatus='Can''t Complete' where TaskID=xx;- surround with single quotes and double any single quotes within the string. Where's the code that assembles the SQL - can you do this? Actually if your query is in your C# code you should be using a parameterized query instead so you can pass the value to Oracle without inserting it into your string.