Note that there are some explanatory texts on larger screens.

plurals
  1. POC# DataTable forgetting it's column(s) after extended use
    text
    copied!<p>I am using a DataTable in my .Net 3.5 application to store 1 column, with some records that contain a filename.</p> <p>Here is my code on how and where I initialize my DataTable:</p> <pre><code>public partial class MainForm : Form { DataTable memTable_CurrentTransfers = new DataTable(); private void MainForm_Load(object sender, EventArgs e) { memTable_CurrentTransfers.Columns.Add("fileName", typeof (string)); </code></pre> <p><br>Here is how I add the filename to my DataTable in another method of my application:</p> <pre><code>memTable_CurrentTransfers.Rows.Add(fileName); </code></pre> <p><br>Every 30 minutes, I launch a thread that executes this code:</p> <pre><code>public void CheckUploads() { DataView view2 = memTable_CurrentTransfers.DefaultView; for (int i = 0; i &lt; view2.Count; i++) { string tmpString = view2[i][0].ToString(); </code></pre> <p><br>Everything works great, but after after my application is running for a while, my users are starting to get this error in the CheckUploads() method</p> <blockquote> <p>The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at System.Data.DataView.get_Item(Int32 recordIndex)</p> </blockquote> <p><br>I think that my column is disappearing from my DataTable.</p> <p>Can please anyone tell me why this is happening and how I can stop this from occurring? Is there another way I should be initializing my DataTable so it is available from all methods inside of my application?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload