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?
You can replace
'with''. The quotes define a text, so your code opens, but doesnt close the text ‘area’ by insertingCan't.