# ShapeFileFeatureLayer.QueryTools.ExecuteQuery()

**URL:** <https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325>\
**Category:** WinForms\
**Created:** [April 2, 2009, 1:29pm UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325 "2009-04-02T13:29:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nelson](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/dec6dc/32.png) [@Nelson](https://community.thinkgeo.com/u/Nelson)\
**Post date:** [April 2, 2009, 1:29pm UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/1 "2009-04-02T13:29:28Z")

</div>

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

SELECT&nbsp;\*&nbsp;FROM&nbsp;LOTS&nbsp;WHERE&nbsp;LOTS\_&nbsp;=&nbsp;'24'

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

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

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

&nbsp;

SELECT&nbsp;\*&nbsp;FROM&nbsp;LOTS&nbsp;WHERE&nbsp;"LOTS\_"&nbsp;=&nbsp;'24'

---

<div class="post-metadata">

**Author:** ![Nelson](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/dec6dc/32.png) [@Nelson](https://community.thinkgeo.com/u/Nelson)\
**Post date:** [April 2, 2009, 1:54pm UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/2 "2009-04-02T13:54:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [April 3, 2009, 5:36am UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/3 "2009-04-03T05:36:50Z")

</div>

Can&nbsp;you&nbsp;have&nbsp;a&nbsp;quick&nbsp;try&nbsp;on&nbsp;this?&nbsp;  
&nbsp;&nbsp;  
&nbsp;SELECT&nbsp;\*&nbsp;FROM&nbsp;LOTS&nbsp;WHERE&nbsp;[LOTS\_]&nbsp;=&nbsp;‘24’

---

<div class="post-metadata">

**Author:** ![Nelson](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/dec6dc/32.png) [@Nelson](https://community.thinkgeo.com/u/Nelson)\
**Post date:** [April 3, 2009, 6:21am UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/4 "2009-04-03T06:21:03Z")

</div>

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

&nbsp;

Syntax&nbsp;error&nbsp;in&nbsp;query&nbsp;expression&nbsp;'[[LOTS]\_]&nbsp;=&nbsp;'2''.

&nbsp;

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

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [April 7, 2009, 8:33pm UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/5 "2009-04-07T20:33:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nelson](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/dec6dc/32.png) [@Nelson](https://community.thinkgeo.com/u/Nelson)\
**Post date:** [April 9, 2009, 7:47am UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/6 "2009-04-09T07:47:16Z")

</div>

No&nbsp;problem,&nbsp;Ben.&nbsp;Thank&nbsp;you.

---

<div class="post-metadata">

**Author:** ![Ben](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/ben/32/25720_2.png) [@Ben](https://community.thinkgeo.com/u/Ben)\
**Post date:** [April 9, 2009, 10:13pm UTC](https://community.thinkgeo.com/t/shapefilefeaturelayer-querytools-executequery/325/7 "2009-04-09T22:13:13Z")

</div>

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