Dataset not Clearing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tshad

    #1

    Dataset not Clearing

    I am trying to clear my dataset each time I read a new csv file but it seems
    to keep the data from the previous time.

    If I do:
    *************** *************** *************** *************** *************** *****
    foreach (string strFile in strFiles)
    {
    ds.Clear();
    da = new OleDbDataAdapte r("SELECT * FROM " +
    Path.GetFileNam e(strFile),csvC onnection);
    da.Fill(ds);

    foreach (DataTable dt in ds.Tables)
    {
    for (int i=0;i<dt.Column s.Count-1;i++)
    {
    switch(i)
    {
    case 0:
    formName = dt.Columns[i].ColumnName.Rep lace("Form ","");
    dt.Columns[i].ColumnName = "FieldName" ;
    break;
    *************** *************** *************** *************** *************** ******

    The second time I read a file (after the ds.Clear();) I find that my
    dt.Columns[i].ColumnName will be equal to "FieldName" , which is what I
    change the column to the first time around!!!

    Why is that?

    It should be what is in the first row, first column of the table, since I
    wiped out the table. If not, how do I get it to work correctly?

    Thanks,

    Tom



Working...