# Dbf column

**URL:** <https://community.thinkgeo.com/t/dbf-column/1144>\
**Category:** WinForms\
**Created:** [April 8, 2010, 9:50pm UTC](https://community.thinkgeo.com/t/dbf-column/1144 "2010-04-08T21:50:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [April 8, 2010, 9:50pm UTC](https://community.thinkgeo.com/t/dbf-column/1144/1 "2010-04-08T21:50:29Z")

</div>

Hello&nbsp;all,

in&nbsp;the&nbsp;past,&nbsp;i&nbsp;insert/modify/delete&nbsp;dbf&nbsp;column&nbsp;from&nbsp;original&nbsp;file.

I&nbsp;create&nbsp;new&nbsp;shp&nbsp;file&nbsp;(and&nbsp;insert/&nbsp;modify/&nbsp;delete&nbsp;column&nbsp;name)&nbsp;and&nbsp;copy&nbsp;all&nbsp;data&nbsp;from&nbsp;original&nbsp;file...

if&nbsp;I&nbsp;want&nbsp;to&nbsp;insert/modify/delete&nbsp;dbf&nbsp;column,&nbsp;could&nbsp;i&nbsp;do&nbsp;this&nbsp;in&nbsp;original&nbsp;file?&nbsp;(I&nbsp;mean&nbsp;that&nbsp;I&nbsp;don't&nbsp;want&nbsp;to&nbsp;create&nbsp;a&nbsp;new&nbsp;file&nbsp;and&nbsp;copy&nbsp;data)

have&nbsp;any&nbsp;method&nbsp;to&nbsp;achieve&nbsp;it?

---

<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, 2010, 12:22am UTC](https://community.thinkgeo.com/t/dbf-column/1144/2 "2010-04-09T00:22:17Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;In&nbsp;the&nbsp;upcoming&nbsp;version&nbsp;we&nbsp;will&nbsp;release&nbsp;on&nbsp;May&nbsp;1st,&nbsp;a&nbsp;GeoDbf&nbsp;class&nbsp;will&nbsp;be&nbsp;exposed&nbsp;with&nbsp;which&nbsp;you&nbsp;can&nbsp;directly&nbsp;operate&nbsp;a&nbsp;dbf&nbsp;file.&nbsp;But&nbsp;we&nbsp;still&nbsp;don’t&nbsp;have&nbsp;the&nbsp;method&nbsp;to&nbsp;insert/modify/delete&nbsp;a&nbsp;column.&nbsp;We&nbsp;used&nbsp;to&nbsp;have&nbsp;this&nbsp;function&nbsp;in&nbsp;Map&nbsp;Suite&nbsp;2.0&nbsp;but&nbsp;as&nbsp;dbf&nbsp;structure&nbsp;itself&nbsp;is&nbsp;not&nbsp;suitable&nbsp;for&nbsp;adding/removing&nbsp;columns,&nbsp;to&nbsp;implement&nbsp;that,&nbsp;internally&nbsp;we&nbsp;need&nbsp;to&nbsp;create&nbsp;a&nbsp;new&nbsp;dbf&nbsp;file,&nbsp;copy&nbsp;all&nbsp;the&nbsp;data&nbsp;there&nbsp;and&nbsp;replace&nbsp;the&nbsp;original&nbsp;file.&nbsp;This&nbsp;method&nbsp;is&nbsp;easily&nbsp;to&nbsp;be&nbsp;abused&nbsp;and&nbsp;it&nbsp;has&nbsp;a&nbsp;low&nbsp;performance.&nbsp;For&nbsp;example,&nbsp;if&nbsp;I&nbsp;want&nbsp;to&nbsp;add&nbsp;2&nbsp;new&nbsp;columns&nbsp;and&nbsp;call&nbsp;AddColumn()&nbsp;method&nbsp;twice,&nbsp;internally&nbsp;it&nbsp;will&nbsp;do&nbsp;the&nbsp;copies&nbsp;twice.&nbsp;That’s&nbsp;a&nbsp;reason&nbsp;we&nbsp;removed&nbsp;this&nbsp;method&nbsp;in&nbsp;3.0&nbsp;kind&nbsp;of&nbsp;reminding&nbsp;people&nbsp;DBF&nbsp;is&nbsp;not&nbsp;suitable&nbsp;to&nbsp;do&nbsp;this&nbsp;operation,&nbsp;if&nbsp;you&nbsp;implement&nbsp;it&nbsp;by&nbsp;yourself,&nbsp;you&nbsp;can&nbsp;have&nbsp;a&nbsp;better&nbsp;performance&nbsp;and&nbsp;have&nbsp;a&nbsp;good&nbsp;understand&nbsp;about&nbsp;the&nbsp;logic&nbsp;behind&nbsp;the&nbsp;scene.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [April 9, 2010, 4:34am UTC](https://community.thinkgeo.com/t/dbf-column/1144/3 "2010-04-09T04:34:08Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Ben&nbsp;  
&nbsp;I’d&nbsp;like&nbsp;to&nbsp;make&nbsp;sure…In&nbsp;addition&nbsp;to&nbsp;insert/delete&nbsp;columns,&nbsp;current&nbsp;version&nbsp;still&nbsp;can&nbsp;not&nbsp;modify&nbsp;column&nbsp;name?

---

<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, 2010, 4:53am UTC](https://community.thinkgeo.com/t/dbf-column/1144/4 "2010-04-09T04:53:07Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;It&nbsp;cannot&nbsp;in&nbsp;the&nbsp;current&nbsp;version.&nbsp;We&nbsp;are&nbsp;consider&nbsp;adding&nbsp;it&nbsp;to&nbsp;the&nbsp;next&nbsp;version&nbsp;released&nbsp;on&nbsp;May&nbsp;1st,&nbsp;thanks&nbsp;for&nbsp;reminding.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Ben

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [April 9, 2010, 4:57am UTC](https://community.thinkgeo.com/t/dbf-column/1144/5 "2010-04-09T04:57:54Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Ben&nbsp;  
&nbsp;does&nbsp;any&nbsp;temporarily&nbsp;.dll&nbsp;to&nbsp;release?&nbsp;  
&nbsp;because&nbsp;i’d&nbsp;like&nbsp;to&nbsp;use&nbsp;this&nbsp;method&nbsp;for&nbsp;modify&nbsp;dbf&nbsp;column.&nbsp;  
&nbsp;if&nbsp;you&nbsp;can,&nbsp;give&nbsp;me&nbsp;new&nbsp;.dll&nbsp;and&nbsp;a&nbsp;simple&nbsp;sample.&nbsp;  
&nbsp;Thanks&nbsp;a&nbsp;lot.&nbsp;:)

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [April 12, 2010, 2:41am UTC](https://community.thinkgeo.com/t/dbf-column/1144/6 "2010-04-12T02:41:39Z")

</div>

Carol,

We&nbsp;are&nbsp;planning&nbsp;to&nbsp;add&nbsp;an&nbsp;API&nbsp;as&nbsp;following&nbsp;as&nbsp;soon&nbsp;as&nbsp;possible&nbsp;and&nbsp;it&nbsp;should&nbsp;be&nbsp;available&nbsp;in&nbsp;next&nbsp;public&nbsp;release&nbsp;around&nbsp;May&nbsp;1st.  
`public void UpdateColumnName(int columnNumber, string newColummName)`  
&nbsp;  
Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Thanks.  
&nbsp;  
Yale

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 25, 2010, 9:40pm UTC](https://community.thinkgeo.com/t/dbf-column/1144/7 "2010-05-25T21:40:02Z")

</div>

Yale,&nbsp;  
&nbsp;I&nbsp;try&nbsp;to&nbsp;use&nbsp;new&nbsp;API&nbsp;as&nbsp;follows:&nbsp;  
&nbsp;Could&nbsp;you&nbsp;help&nbsp;me&nbsp;to&nbsp;see&nbsp;what’s&nbsp;wrong?&nbsp;  
&nbsp;Road\_AL.dbf&nbsp;has&nbsp;many&nbsp;records&nbsp;and&nbsp;2&nbsp;columns.&nbsp;  
&nbsp;&nbsp;  
&nbsp;GeoDbf&nbsp;dbfRoad&nbsp;=&nbsp;new&nbsp;GeoDbf(@“D:\Road\_AL.dbf”,&nbsp;DbfReadWriteMode.ReadWrite);&nbsp;  
&nbsp;int&nbsp;recordCount=dbfRoad.RecordCount;&nbsp;//the&nbsp;result&nbsp;of&nbsp;recordCount=0.&nbsp;&nbsp;  
&nbsp;dbfRoad.UpdateColumnName(2,&nbsp;“ID”);&nbsp;//error:&nbsp;Your&nbsp;input&nbsp;index&nbsp;is&nbsp;out&nbsp;of&nbsp;bound&nbsp;  
&nbsp;dbfRoad.DeleteRecord(1);

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 25, 2010, 10:22pm UTC](https://community.thinkgeo.com/t/dbf-column/1144/8 "2010-05-25T22:22:32Z")

</div>

Carol,

Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;question.

To&nbsp;use&nbsp;the&nbsp;Dbf&nbsp;module,&nbsp;you&nbsp;may&nbsp;keep&nbsp;the&nbsp;Open&nbsp;&&nbsp;Close&nbsp;mode.&nbsp;See&nbsp;following&nbsp;code&nbsp;snippet:

`string dbfFile = @"..\Countries02.dbf";GeoDbf dbfRoad = new GeoDbf(dbfFile, DbfReadWriteMode.ReadWrite);dbfRoad.Open();int recordCount = dbfRoad.RecordCount; dbfRoad.UpdateColumnName(2, "ID"); dbfRoad.DeleteRecord(1);dbfRoad.Close();`

Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.

Thanks.

Yale  
  
&nbsp;

---

<div class="post-metadata">

**Author:** ![Carol](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@Carol](https://community.thinkgeo.com/u/Carol)\
**Post date:** [May 25, 2010, 10:50pm UTC](https://community.thinkgeo.com/t/dbf-column/1144/9 "2010-05-25T22:50:19Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;reply,&nbsp;Yale&nbsp;  
&nbsp;&nbsp;  
&nbsp;dbfRoad.UpdateColumnName(2,&nbsp;“ID”);&nbsp;//I&nbsp;open&nbsp;my&nbsp;dbf&nbsp;file,&nbsp;the&nbsp;column&nbsp;name&nbsp;still&nbsp;doesn’t&nbsp;change.&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [May 26, 2010, 12:46am UTC](https://community.thinkgeo.com/t/dbf-column/1144/10 "2010-05-26T00:46:09Z")

</div>

Carol,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;reporting.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;This&nbsp;is&nbsp;a&nbsp;bug&nbsp;in&nbsp;the&nbsp;new&nbsp;added&nbsp;API&nbsp;UpdateColumnName,&nbsp;we&nbsp;have&nbsp;modified&nbsp;the&nbsp;code&nbsp;and&nbsp;fix&nbsp;it.&nbsp;It&nbsp;will&nbsp;be&nbsp;available&nbsp;in&nbsp;next&nbsp;public&nbsp;release.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Any&nbsp;more&nbsp;questions&nbsp;just&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;me&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Yale&nbsp;
