<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcMap retains fields of removed Table. in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-retains-fields-of-removed-table/m-p/336351#M8805</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have developed an AddIn for ArcMap 10.1 using VB .net 2010.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My tool writes data it creates to a dBase file which gets loaded into the TOC. During processing the tool can create up to 25 fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sometimes a user will need to rebuild this table with its initial set of 3 fields (by selecting a button on toolbar).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When the user clicks on the create table button my code searches for the table in the TOC and removes it with the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; pStandAloneTableCollection.RemoveStandaloneTable(pStandAloneTable) pMXDocument.UpdateContents()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code then continues by deleting the existing dBase file and then recreates with the default set of 3 fields. This all works fine. The table is loaded back into the TOC with the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;pStandAloneTable = New StandaloneTableClass pStandAloneTable.Table = pTable pStandAloneTable.Name = Me.TextBox1.Text pStandAloneTableCollection.AddStandaloneTable(pStandAloneTable) pMXDocument.UpdateContents()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I then go to the Table in ArcMap and open it I see all the previous fields (with zero values) and not an attribute table with just 3 fields. It's as if ArcMap has held onto the schema of the table it had removed, any ideas on how to force a refresh?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Mar 2013 16:37:52 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2013-03-14T16:37:52Z</dc:date>
    <item>
      <title>ArcMap retains fields of removed Table.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-retains-fields-of-removed-table/m-p/336351#M8805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have developed an AddIn for ArcMap 10.1 using VB .net 2010.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My tool writes data it creates to a dBase file which gets loaded into the TOC. During processing the tool can create up to 25 fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sometimes a user will need to rebuild this table with its initial set of 3 fields (by selecting a button on toolbar).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When the user clicks on the create table button my code searches for the table in the TOC and removes it with the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; pStandAloneTableCollection.RemoveStandaloneTable(pStandAloneTable) pMXDocument.UpdateContents()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code then continues by deleting the existing dBase file and then recreates with the default set of 3 fields. This all works fine. The table is loaded back into the TOC with the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;pStandAloneTable = New StandaloneTableClass pStandAloneTable.Table = pTable pStandAloneTable.Name = Me.TextBox1.Text pStandAloneTableCollection.AddStandaloneTable(pStandAloneTable) pMXDocument.UpdateContents()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I then go to the Table in ArcMap and open it I see all the previous fields (with zero values) and not an attribute table with just 3 fields. It's as if ArcMap has held onto the schema of the table it had removed, any ideas on how to force a refresh?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 16:37:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-retains-fields-of-removed-table/m-p/336351#M8805</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-03-14T16:37:52Z</dc:date>
    </item>
    <item>
      <title>It was how I was deleting the table.</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-retains-fields-of-removed-table/m-p/336352#M8806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FYI I resolved the problem, it appears to be with the way I was deleting the dBase file. Originally I was deleting the table using the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;My.Computer.FileSystem.DeleteFile(sFullPath)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed this to the more verbose method using ArcObjects:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Dim pWorkspaceFactory As IWorkspaceFactory pWorkspaceFactory = New ShapefileWorkspaceFactoryClass Dim pFeatureWorkspace As IFeatureWorkspace pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(sPath, 0) pTable = pFeatureWorkspace.OpenTable(Me.TextBox1.Text) Dim pDataset As IDataset pDataset = DirectCast(pTable, IDataset) If pDataset.CanDelete Then &amp;nbsp;&amp;nbsp;&amp;nbsp; ' Delete and clean up &amp;nbsp;&amp;nbsp;&amp;nbsp; pDataset.Delete() &amp;nbsp;&amp;nbsp;&amp;nbsp; pTable = Nothing &amp;nbsp;&amp;nbsp;&amp;nbsp; pTable = Nothing &amp;nbsp;&amp;nbsp;&amp;nbsp; pFeatureWorkspace = Nothing &amp;nbsp;&amp;nbsp;&amp;nbsp; pWorkspaceFactory = Nothing End If&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This has resolved my problem.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 15:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/arcmap-retains-fields-of-removed-table/m-p/336352#M8806</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2013-03-15T15:45:52Z</dc:date>
    </item>
  </channel>
</rss>

