I'm trying to query values using a cursor and loop for the process of removing diacritics. The problem I am running in to is that when I try to create a WhereClause
like so...
qf.WhereClause = "\""+fieldname+"\" = "+"'"+address+"'";
I get a COMException about my query if the value of address has a single quote in it (i.e. Land o'Lakes
). I have tried escaping the ' with address.Replace("'","\'")
but the resulting string is unchanged. When I attempted to double-escape with address.Replace("'","\\'")
, the string ends up with both backslashes.
What should I do?
Answer
I think it might matter what type of data source you are hitting but in general I suspect that doubling the single quote marks is the solution. So address.Replace( "'", "''"); should work.
No comments:
Post a Comment