I am using trying to use the escape character for " to construct an SQL string like follows:
selSQL += " WHERE [" + sFieldArr[i, 0] + "]" + op + "\"" + sFieldArr[i, 1] + "\"";
but it keeps producing the string incorrectly, for example
WHERE [State]=\"Illinois\"
How should I be escaping the double quotes here?
Update: As pointed out in the comments, the escape characters were actually working correctly, they just appeared to be working incorrectly in the debugger. The problem was that SQL Server was interpreting this as a column name - see this article: https://support.microsoft.com/en-us/kb/222664
Solution is to use two single quotes instead of one double quotes.