# Cannot Perform SQL Query on Tab File Format Files?

**URL:** <https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290>\
**Category:** WPF\
**Created:** [September 10, 2012, 8:16pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290 "2012-09-10T20:16:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 10, 2012, 8:16pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/1 "2012-09-10T20:16:07Z")

</div>

I'm&nbsp;trying&nbsp;to&nbsp;perform&nbsp;a&nbsp;SQL&nbsp;query&nbsp;on&nbsp;a&nbsp;TAB&nbsp;file.

The&nbsp;error&nbsp;message&nbsp;I&nbsp;get&nbsp;indicates&nbsp;that&nbsp;I&nbsp;should&nbsp;check&nbsp;the&nbsp;CanExecuteSqlQueries&nbsp;property&nbsp;on&nbsp;the&nbsp;layer&nbsp;which&nbsp;is&nbsp;false.

Is&nbsp;this&nbsp;correct?&nbsp;The&nbsp;corresponding&nbsp;DAT&nbsp;file&nbsp;is&nbsp;a&nbsp;dbase&nbsp;file&nbsp;and&nbsp;I&nbsp;can&nbsp;get&nbsp;properties&nbsp;from&nbsp;it&nbsp;for&nbsp;the&nbsp;selected&nbsp;feature.

Is&nbsp;there&nbsp;any&nbsp;way&nbsp;to&nbsp;perform&nbsp;sql&nbsp;queries&nbsp;on&nbsp;tab&nbsp;files?

Cheers

Steve

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 10, 2012, 9:06pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/2 "2012-09-10T21:06:50Z")

</div>

I&nbsp;see&nbsp;from&nbsp;a&nbsp;previous&nbsp;answer&nbsp;that&nbsp;sql&nbsp;queries&nbsp;are&nbsp;not&nbsp;supported&nbsp;on&nbsp;tab&nbsp;files.&nbsp;The&nbsp;answer&nbsp;was&nbsp;back&nbsp;in&nbsp;February.&nbsp;Any&nbsp;idea&nbsp;when&nbsp;this&nbsp;will&nbsp;be&nbsp;added?&nbsp;Makes&nbsp;tab&nbsp;files&nbsp;useless&nbsp;for&nbsp;me&nbsp;if&nbsp;I&nbsp;cannot&nbsp;search&nbsp;and&nbsp;highlight&nbsp;a&nbsp;particular&nbsp;feature.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 11, 2012, 4:27am UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/3 "2012-09-11T04:27:36Z")

</div>

Hi&nbsp;Steve,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;to&nbsp;tell&nbsp;you&nbsp;we&nbsp;haven’t&nbsp;find&nbsp;a&nbsp;way&nbsp;to&nbsp;access&nbsp;the&nbsp;.dat&nbsp;file&nbsp;of&nbsp;the&nbsp;tab&nbsp;file.&nbsp;The&nbsp;dat&nbsp;file&nbsp;has&nbsp;the&nbsp;same&nbsp;structure&nbsp;as&nbsp;dbf&nbsp;file,&nbsp;we&nbsp;tried&nbsp;to&nbsp;change&nbsp;the&nbsp;extension&nbsp;of&nbsp;dat&nbsp;file&nbsp;to&nbsp;dbf,&nbsp;it&nbsp;could&nbsp;be&nbsp;queried&nbsp;by&nbsp;Oledb,&nbsp;but&nbsp;when&nbsp;we&nbsp;change&nbsp;it&nbsp;back,&nbsp;it&nbsp;can&nbsp;not.&nbsp;So&nbsp;we’ll&nbsp;keep&nbsp;on&nbsp;doing&nbsp;the&nbsp;research&nbsp;on&nbsp;this&nbsp;and&nbsp;maybe&nbsp;one&nbsp;day&nbsp;we’ll&nbsp;find&nbsp;out&nbsp;the&nbsp;solution.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 11, 2012, 4:07pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/4 "2012-09-11T16:07:23Z")

</div>

Hi&nbsp;Edgar&nbsp;  
&nbsp;&nbsp;  
&nbsp;I’ll&nbsp;see&nbsp;if&nbsp;I&nbsp;can&nbsp;find&nbsp;a&nbsp;way&nbsp;round&nbsp;this&nbsp;that&nbsp;you&nbsp;can&nbsp;use.&nbsp;  
&nbsp;&nbsp;  
&nbsp;OleDb&nbsp;causes&nbsp;me&nbsp;problems&nbsp;with&nbsp;other&nbsp;files.&nbsp;If&nbsp;I&nbsp;have&nbsp;lots&nbsp;of&nbsp;shape&nbsp;files&nbsp;with&nbsp;long&nbsp;filenames&nbsp;where&nbsp;the&nbsp;first&nbsp;8&nbsp;characters&nbsp;are&nbsp;the&nbsp;same,&nbsp;it&nbsp;can&nbsp;confuse&nbsp;OleDb&nbsp;which&nbsp;seems&nbsp;to&nbsp;use&nbsp;short&nbsp;filenames.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [September 11, 2012, 4:43pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/5 "2012-09-11T16:43:14Z")

</div>

Hello&nbsp;Steve,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;help,&nbsp;please&nbsp;let&nbsp;us&nbsp;know&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;way.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Also&nbsp;don’t&nbsp;hesitate&nbsp;to&nbsp;let&nbsp;us&nbsp;know&nbsp;your&nbsp;problem,&nbsp;we&nbsp;are&nbsp;happy&nbsp;to&nbsp;help&nbsp;you.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 13, 2012, 11:04pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/6 "2012-09-13T23:04:56Z")

</div>

Hi&nbsp;Gary&nbsp;  
&nbsp;&nbsp;  
&nbsp;One&nbsp;possible&nbsp;solution&nbsp;is&nbsp;for&nbsp;us&nbsp;to&nbsp;create&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;.DAT&nbsp;file&nbsp;as&nbsp;a&nbsp;.DBF&nbsp;file.&nbsp;This&nbsp;depends&nbsp;on&nbsp;how&nbsp;the&nbsp;layer&nbsp;determines&nbsp;CanExecuteSqlQuery&nbsp;-&nbsp;is&nbsp;this&nbsp;based&nbsp;purely&nbsp;on&nbsp;the&nbsp;layer&nbsp;type&nbsp;or&nbsp;is&nbsp;it&nbsp;determined&nbsp;by&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;.DBF&nbsp;file&nbsp;present?&nbsp;If&nbsp;the&nbsp;former&nbsp;can&nbsp;this&nbsp;be&nbsp;changed&nbsp;to&nbsp;the&nbsp;latter&nbsp;then&nbsp;I&nbsp;will&nbsp;be&nbsp;able&nbsp;to&nbsp;work&nbsp;round&nbsp;the&nbsp;missing&nbsp;search&nbsp;functionality.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 16, 2012, 8:58pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/7 "2012-09-16T20:58:11Z")

</div>

Steve,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thank&nbsp;you&nbsp;for&nbsp;you&nbsp;suggest,&nbsp;creating&nbsp;a&nbsp;copy&nbsp;does&nbsp;solve&nbsp;the&nbsp;execute&nbsp;problem,&nbsp;but&nbsp;what&nbsp;time&nbsp;to&nbsp;copy&nbsp;that?&nbsp;Only&nbsp;two&nbsp;ideas&nbsp;come&nbsp;to&nbsp;my&nbsp;mind,&nbsp;  
&nbsp;1),&nbsp;before&nbsp;the&nbsp;executing,&nbsp;copy&nbsp;the&nbsp;file&nbsp;and&nbsp;if&nbsp;there&nbsp;are&nbsp;changes,&nbsp;replace&nbsp;the&nbsp;original&nbsp;file.&nbsp;  
&nbsp;2),&nbsp;copy&nbsp;the&nbsp;file&nbsp;when&nbsp;Opening&nbsp;and&nbsp;replace&nbsp;the&nbsp;file&nbsp;when&nbsp;closing.&nbsp;  
&nbsp;&nbsp;  
&nbsp;But&nbsp;the&nbsp;two&nbsp;ways&nbsp;both&nbsp;have&nbsp;the&nbsp;performance&nbsp;issue&nbsp;if&nbsp;the&nbsp;file&nbsp;is&nbsp;big.&nbsp;We’ll&nbsp;continue&nbsp;working&nbsp;on&nbsp;this&nbsp;till&nbsp;we&nbsp;find&nbsp;a&nbsp;solution.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 16, 2012, 9:02pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/8 "2012-09-16T21:02:40Z")

</div>

Hi&nbsp;Edgar

I'm&nbsp;not&nbsp;suggesting&nbsp;you&nbsp;should&nbsp;copy&nbsp;the&nbsp;file.&nbsp;What&nbsp;I'm&nbsp;suggesting&nbsp;is&nbsp;that&nbsp;you&nbsp;should&nbsp;check&nbsp;to&nbsp;see&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;.dbf&nbsp;and&nbsp;if&nbsp;so&nbsp;allow&nbsp;a&nbsp;sql&nbsp;query&nbsp;to&nbsp;be&nbsp;run.&nbsp;

I&nbsp;have&nbsp;a&nbsp;GIS&nbsp;utility&nbsp;that&nbsp;my&nbsp;customers&nbsp;use&nbsp;to&nbsp;import&nbsp;GIS&nbsp;layers&nbsp;into&nbsp;our&nbsp;system.&nbsp;As&nbsp;part&nbsp;of&nbsp;an&nbsp;import&nbsp;I&nbsp;generate&nbsp;index&nbsp;files.&nbsp;I&nbsp;can&nbsp;also&nbsp;copy&nbsp;.dat&nbsp;files&nbsp;as&nbsp;.dbf&nbsp;files.

My&nbsp;main&nbsp;problem&nbsp;is&nbsp;that&nbsp;I&nbsp;think&nbsp;you&nbsp;turn&nbsp;off&nbsp;sql&nbsp;queries&nbsp;for&nbsp;.tab&nbsp;files.&nbsp;What&nbsp;I'm&nbsp;asking&nbsp;is&nbsp;for&nbsp;you&nbsp;not&nbsp;to&nbsp;do&nbsp;this&nbsp;but&nbsp;instead&nbsp;to&nbsp;check&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;.dbf&nbsp;file.

Cheers

Steve

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 16, 2012, 11:47pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/9 "2012-09-16T23:47:31Z")

</div>

Oh&nbsp;I&nbsp;see,&nbsp;I&nbsp;think&nbsp;there&nbsp;is&nbsp;a&nbsp;workaround&nbsp;for&nbsp;you.  
&nbsp;  
`public class MyTabFeatureLayer : TabFeatureLayer    {        public MyTabFeatureLayer()            : this(string.Empty, TabFileReadWriteMode.ReadOnly)        { }        public MyTabFeatureLayer(string fileName)            : this(fileName, TabFileReadWriteMode.ReadOnly)        { }        public MyTabFeatureLayer(string fileName, TabFileReadWriteMode mode)        {            FeatureSource = new MyTabFeatureSource(fileName, mode);        }    }    public class MyTabFeatureSource : TabFeatureSource    {        public MyTabFeatureSource()            : base()        { }        public MyTabFeatureSource(string fileName)            : base(fileName)        { }        public MyTabFeatureSource(string fileName, TabFileReadWriteMode mode)            : base(fileName, mode)        { }        protected override bool CanExecuteSqlQueryCore        {            get            {                return true;            }        }        protected override DataTable ExecuteQueryCore(string sqlStatement)        {            string fileName = Path.GetDirectoryName(this.TabPathFilename) + “\” + Path.GetFileNameWithoutExtension(this.TabPathFilename) + “.dbf”;            if (!File.Exists(fileName))            {                File.Copy(this.TabPathFilename, fileName);            }            OleDbConnection conn = new OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + Path.GetDirectoryName(this.TabPathFilename) + “\;Extended Properties=dBASE III”);            DataTable dt = new DataTable();            OleDbDataAdapter adapter = new OleDbDataAdapter(sqlStatement, conn);            conn.Open();            adapter.Fill(dt);            conn.Dispose();            adapter.Dispose();            return dt;        }    }`  
&nbsp;  
The&nbsp;sample&nbsp;code&nbsp;just&nbsp;overrided&nbsp;the&nbsp;ExecuteQueryCore&nbsp;method,&nbsp;you&nbsp;can&nbsp;overrided&nbsp;the&nbsp;others&nbsp;like&nbsp;that.&nbsp;We’ll&nbsp;keep&nbsp;on&nbsp;researching&nbsp;to&nbsp;find&nbsp;a&nbsp;good&nbsp;solution.  
&nbsp;  
Hope&nbsp;it&nbsp;helps,  
&nbsp;  
Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 18, 2012, 4:56pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/10 "2012-09-18T16:56:31Z")

</div>

Thanks&nbsp;Edgar.&nbsp;That&nbsp;works&nbsp;great.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;have&nbsp;found&nbsp;a&nbsp;way&nbsp;to&nbsp;access&nbsp;the&nbsp;.DAT&nbsp;files&nbsp;from&nbsp;a&nbsp;SQL&nbsp;query.&nbsp;If&nbsp;you&nbsp;perform&nbsp;a&nbsp;query&nbsp;like&nbsp;select&nbsp;\*&nbsp;from&nbsp;parcels&nbsp;then&nbsp;the&nbsp;odbc&nbsp;driver&nbsp;looks&nbsp;for&nbsp;a&nbsp;parcels.dbf&nbsp;file.&nbsp;If&nbsp;you&nbsp;perform&nbsp;a&nbsp;query&nbsp;like&nbsp;select&nbsp;\*&nbsp;from&nbsp;parcels.dat&nbsp;then&nbsp;you&nbsp;can&nbsp;specify&nbsp;the&nbsp;exact&nbsp;file&nbsp;to&nbsp;query.&nbsp;Tried&nbsp;it&nbsp;and&nbsp;it&nbsp;seems&nbsp;to&nbsp;work.&nbsp;May&nbsp;help&nbsp;you&nbsp;move&nbsp;forward.&nbsp;  
&nbsp;&nbsp;  
&nbsp;One&nbsp;more&nbsp;question.&nbsp;How&nbsp;do&nbsp;you&nbsp;link&nbsp;the&nbsp;row&nbsp;in&nbsp;the&nbsp;query&nbsp;result&nbsp;set&nbsp;to&nbsp;the&nbsp;shape?&nbsp;In&nbsp;a&nbsp;shape&nbsp;file&nbsp;you&nbsp;can&nbsp;add&nbsp;a&nbsp;recid&nbsp;column&nbsp;using&nbsp;the&nbsp;ShapeFileFeatureLayer.BuildRecordIdColumn&nbsp;command.&nbsp;There&nbsp;does&nbsp;not&nbsp;appear&nbsp;to&nbsp;be&nbsp;a&nbsp;similar&nbsp;command&nbsp;for&nbsp;a&nbsp;TabFeatureLayer?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve&nbsp;

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 18, 2012, 9:55pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/11 "2012-09-18T21:55:10Z")

</div>

Hi&nbsp;Edgar&nbsp;  
&nbsp;&nbsp;  
&nbsp;After&nbsp;further&nbsp;testing&nbsp;my&nbsp;suggestion&nbsp;above&nbsp;about&nbsp;adding&nbsp;the&nbsp;extension&nbsp;to&nbsp;the&nbsp;query&nbsp;does&nbsp;not&nbsp;work.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;still&nbsp;need&nbsp;the&nbsp;answer&nbsp;to&nbsp;the&nbsp;question:&nbsp;How&nbsp;do&nbsp;you&nbsp;link&nbsp;the&nbsp;row&nbsp;in&nbsp;the&nbsp;query&nbsp;result&nbsp;set&nbsp;to&nbsp;the&nbsp;shape&nbsp;in&nbsp;tab&nbsp;files?&nbsp;In&nbsp;a&nbsp;shape&nbsp;file&nbsp;you&nbsp;can&nbsp;add&nbsp;a&nbsp;recid&nbsp;column&nbsp;using&nbsp;the&nbsp;ShapeFileFeatureLayer.BuildRecordIdColumn&nbsp;command.&nbsp;There&nbsp;does&nbsp;not&nbsp;appear&nbsp;to&nbsp;be&nbsp;a&nbsp;similar&nbsp;command&nbsp;for&nbsp;a&nbsp;TabFeatureLayer?&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 19, 2012, 3:08am UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/12 "2012-09-19T03:08:33Z")

</div>

Steve,&nbsp;  
&nbsp;  
The&nbsp;tab&nbsp;file’s&nbsp;structure&nbsp;is&nbsp;not&nbsp;the&nbsp;same&nbsp;as&nbsp;the&nbsp;shape&nbsp;file,&nbsp;e.g.&nbsp;the&nbsp;first&nbsp;record’s&nbsp;column&nbsp;value&nbsp;might&nbsp;not&nbsp;be&nbsp;the&nbsp;first&nbsp;record&nbsp;in&nbsp;dat&nbsp;file,&nbsp;so&nbsp;the&nbsp;records&nbsp;in&nbsp;.map&nbsp;file&nbsp;and&nbsp;.dat&nbsp;file&nbsp;are&nbsp;not&nbsp;one&nbsp;on&nbsp;one.&nbsp;The&nbsp;only&nbsp;way&nbsp;to&nbsp;get&nbsp;the&nbsp;feature&nbsp;from&nbsp;the&nbsp;information&nbsp;in&nbsp;table&nbsp;is&nbsp;the&nbsp;following&nbsp;code,  
`            Collection<Feature> features = new Collection<Feature>();            foreach (DataRow item in ta.Rows)            {                //Assume the first column is the “ID” column and it’s the primary key.                string columnValue = item.ItemArray[0].ToString();                features.Add(tab.QueryTools.GetFeaturesByColumnValue(“ID”, columnValue)[0]);            }`  
&nbsp;  
Hope&nbsp;it&nbsp;helps,  
&nbsp;  
Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 24, 2012, 8:54pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/13 "2012-09-24T20:54:05Z")

</div>

&nbsp;Hi&nbsp;Edgar

Thanks&nbsp;for&nbsp;the&nbsp;code.&nbsp;Unfortunately&nbsp;it&nbsp;does&nbsp;not&nbsp;work.&nbsp;The&nbsp;first&nbsp;column&nbsp;in&nbsp;the&nbsp;dat&nbsp;file&nbsp;is&nbsp;not&nbsp;an&nbsp;ID.&nbsp;I&nbsp;cannot&nbsp;see&nbsp;any&nbsp;column&nbsp;that&nbsp;could&nbsp;be&nbsp;an&nbsp;ID.&nbsp;

How&nbsp;does&nbsp;it&nbsp;work&nbsp;going&nbsp;from&nbsp;the&nbsp;shape&nbsp;to&nbsp;the&nbsp;database?&nbsp;This&nbsp;works&nbsp;OK&nbsp;-&nbsp;if&nbsp;I&nbsp;select&nbsp;a&nbsp;shape&nbsp;from&nbsp;the&nbsp;layer&nbsp;I&nbsp;can&nbsp;get&nbsp;all&nbsp;columns&nbsp;so&nbsp;there&nbsp;must&nbsp;be&nbsp;a&nbsp;link&nbsp;from&nbsp;the&nbsp;shape&nbsp;to&nbsp;the&nbsp;database.&nbsp;If&nbsp;so&nbsp;I&nbsp;should&nbsp;be&nbsp;able&nbsp;to&nbsp;follow&nbsp;it&nbsp;the&nbsp;other&nbsp;way.

I&nbsp;have&nbsp;attached&nbsp;the&nbsp;tab&nbsp;file&nbsp;set&nbsp;so&nbsp;you&nbsp;can&nbsp;examine&nbsp;it.

Cheers

Steve

[009\_008\_007\_006\_005\_004\_003\_002\_001\_TEST.zip](https://community.thinkgeo.com/uploads/default/original/2X/d/d04431940877a6e750a8d7026a3eaf070cb1adc0.zip) (432 KB)

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 25, 2012, 7:58pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/14 "2012-09-25T19:58:51Z")

</div>

Hi&nbsp;Steve,

Sorry&nbsp;for&nbsp;my&nbsp;previous&nbsp;reply&nbsp;that&nbsp;I&nbsp;told&nbsp;you&nbsp;the&nbsp;structure&nbsp;is&nbsp;different&nbsp;from&nbsp;the&nbsp;shape&nbsp;file,&nbsp;but&nbsp;in&nbsp;fact,&nbsp;they&nbsp;are&nbsp;the&nbsp;same,&nbsp;that&nbsp;means&nbsp;using&nbsp;GetFeatureById(n)&nbsp;can&nbsp;get&nbsp;the&nbsp;nth&nbsp;record&nbsp;in&nbsp;the&nbsp;dat&nbsp;file,&nbsp;so&nbsp;we&nbsp;added&nbsp;a&nbsp;method&nbsp;TabFeatureSource.BuildRecordIdColumn&nbsp;to&nbsp;build&nbsp;the&nbsp;Id&nbsp;Column&nbsp;in&nbsp;the&nbsp;dat&nbsp;file,&nbsp;after&nbsp;that&nbsp;you&nbsp;can&nbsp;get&nbsp;the&nbsp;features&nbsp;by

`            foreach (DataRow item in ta.Rows)            {                //Assume the last column is the "ID" column and it's the primary key.                string id = item.ItemArray[last].ToString();                features.Add(tab.QueryTools.GetFeatureById(id, ReturningColumnType.AllColumns);            }`

please&nbsp;get&nbsp;6.0.136.0&nbsp;and&nbsp;have&nbsp;a&nbsp;try.

Regards,

Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 25, 2012, 8:13pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/15 "2012-09-25T20:13:57Z")

</div>

Thanks&nbsp;Edgar.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;cannot&nbsp;see&nbsp;136&nbsp;on&nbsp;the&nbsp;download&nbsp;area&nbsp;-&nbsp;only&nbsp;135.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 25, 2012, 10:09pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/16 "2012-09-25T22:09:49Z")

</div>

The&nbsp;136&nbsp;will&nbsp;be&nbsp;available&nbsp;at&nbsp;tomorrow.&nbsp;Please&nbsp;wait&nbsp;for&nbsp;it.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 26, 2012, 6:45pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/17 "2012-09-26T18:45:14Z")

</div>

Hi&nbsp;Edgar&nbsp;  
&nbsp;&nbsp;  
&nbsp;Have&nbsp;downloaded&nbsp;and&nbsp;tested&nbsp;version&nbsp;136.&nbsp;Works&nbsp;fine&nbsp;on&nbsp;the&nbsp;tab&nbsp;file&nbsp;I&nbsp;sent&nbsp;but&nbsp;throws&nbsp;an&nbsp;ArgumentOutOfRangeException&nbsp;exception&nbsp;on&nbsp;one&nbsp;I&nbsp;created&nbsp;through&nbsp;map&nbsp;suite:&nbsp;  
&nbsp;&nbsp;  
&nbsp;{"Index&nbsp;and&nbsp;length&nbsp;must&nbsp;refer&nbsp;to&nbsp;a&nbsp;location&nbsp;within&nbsp;the&nbsp;string.\r\nParameter&nbsp;name:&nbsp;length"}&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.String.InternalSubStringWithChecks(Int32&nbsp;startIndex,&nbsp;Int32&nbsp;length,&nbsp;Boolean&nbsp;fAlwaysCopy)&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;System.String.Substring(Int32&nbsp;startIndex,&nbsp;Int32&nbsp;length)&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.TabFeatureSource.BuildRecordIdColumn(String&nbsp;tabFileName,&nbsp;String&nbsp;fieldName,&nbsp;BuildRecordIdMode&nbsp;rebuildNeeded,&nbsp;Int32&nbsp;startNumber,&nbsp;Encoding&nbsp;encoding)&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;ThinkGeo.MapSuite.Core.TabFeatureLayer.BuildRecordIdColumn(String&nbsp;tabFileName,&nbsp;String&nbsp;fieldName,&nbsp;BuildRecordIdMode&nbsp;rebuildNeeded)&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;at&nbsp;Kern.Client.Windows.Controls.UserControls.MapBase.SaveTabAsset(String&nbsp;userAssetPath,&nbsp;Feature&nbsp;feature,&nbsp;IEnumerable`1&nbsp;assetFieldValues,&nbsp;String&nbsp;safeJobNumber)&nbsp;in&nbsp;c:\TFS\KernMobile\_V5\Main\Kern.Client.Windows\Kern.Client.Windows.Controls\UserControls\MapBase.xaml.cs:line&nbsp;2430&nbsp;  
&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;have&nbsp;attached&nbsp;the&nbsp;tab&nbsp;file&nbsp;that&nbsp;causes&nbsp;the&nbsp;issue.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 26, 2012, 6:46pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/18 "2012-09-26T18:46:00Z")

</div>

&nbsp;Here&nbsp;is&nbsp;the&nbsp;tab&nbsp;file.

[UserAssets.zip](https://community.thinkgeo.com/uploads/default/original/2X/b/b66db4caba74e9d39aa33c100bc5408744879b6b.zip) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [September 26, 2012, 8:04pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/19 "2012-09-26T20:04:19Z")

</div>

Thank&nbsp;you&nbsp;for&nbsp;your&nbsp;file,&nbsp;the&nbsp;issue&nbsp;has&nbsp;been&nbsp;fixed,&nbsp;please&nbsp;get&nbsp;the&nbsp;6.0.137.0&nbsp;and&nbsp;have&nbsp;a&nbsp;try.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Edgar

---

<div class="post-metadata">

**Author:** ![Steve1](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@Steve1](https://community.thinkgeo.com/u/Steve1)\
**Post date:** [September 27, 2012, 4:17pm UTC](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290/20 "2012-09-27T16:17:29Z")

</div>

Hi&nbsp;Edgar&nbsp;  
&nbsp;&nbsp;  
&nbsp;137&nbsp;looks&nbsp;good&nbsp;thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;see&nbsp;that&nbsp;BuildRecordIdColumn&nbsp;generates&nbsp;a&nbsp;dbf&nbsp;file.&nbsp;Does&nbsp;this&nbsp;mean&nbsp;that&nbsp;TAB&nbsp;file&nbsp;ExecuteQuery&nbsp;now&nbsp;looks&nbsp;for&nbsp;.dbf&nbsp;or&nbsp;do&nbsp;I&nbsp;still&nbsp;need&nbsp;to&nbsp;use&nbsp;my&nbsp;own?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Cheers&nbsp;  
&nbsp;&nbsp;  
&nbsp;Steve

[Next page](https://community.thinkgeo.com/t/cannot-perform-sql-query-on-tab-file-format-files/3290.md?page=2)
