ThinkGeo.com    |     Documentation    |     Premium Support

ShapeFileFeatureLayer.QueryTools.ExecuteQuery()

I am having an issue trying to filter by a field that has a trailing underscore. This is fairly common in our scenario. The error generated is:


SELECT * FROM LOTS WHERE LOTS_ = '24'


OleDbException was unhandled: Syntax error in query expression '[LOTS]_='1''.


In the above scenario, LOTS_ is the name of the field. I tried to "escape" the underscore by using two _'s but this did not resolve the issue. What is recommended to work around?


I also tried the following query which did not error but did not return any results either. Other columns work as expected.


 


SELECT * FROM LOTS WHERE "LOTS_" = '24'



This error is actually occurding no matter where the underscore is it seems…

Can you have a quick try on this? 
  
 SELECT * FROM LOTS WHERE [LOTS_] = ‘24’

I tried the above SQL and was given the previous result encapsulated with brackets:


 


Syntax error in query expression '[[LOTS]_] = '2''.


 


Also, I can run a similar query by using Odbc as a connection method directly to a dbf which I imagine is something similar to what you do but with Ole.  That query will return successful though.



Nelson, 
  
 I recreated this problem and that’s a bug. We will work on it and I think it will be corrected in the upcoming version. Thanks for pointing it out and sorry for the inconvenience now. 
  
 Thanks, 
  
 Ben

No problem, Ben. Thank you.

Just let you know we have solved this problem and it will be corrected in the next version, Nelson. 
  
 Ben.