T
tshad
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 OleDbDataAdapter("SELECT * FROM " +
Path.GetFileName(strFile),csvConnection);
da.Fill(ds);
foreach (DataTable dt in ds.Tables)
{
for (int i=0;i<dt.Columns.Count-1;i++)
{
switch(i)
{
case 0:
formName = dt.Columns.ColumnName.Replace("Form ","");
dt.Columns.ColumnName = "FieldName";
break;
*********************************************************************************
The second time I read a file (after the ds.Clear() I find that my
dt.Columns.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
to keep the data from the previous time.
If I do:
********************************************************************************
foreach (string strFile in strFiles)
{
ds.Clear();
da = new OleDbDataAdapter("SELECT * FROM " +
Path.GetFileName(strFile),csvConnection);
da.Fill(ds);
foreach (DataTable dt in ds.Tables)
{
for (int i=0;i<dt.Columns.Count-1;i++)
{
switch(i)
{
case 0:
formName = dt.Columns.ColumnName.Replace("Form ","");
dt.Columns.ColumnName = "FieldName";
break;
*********************************************************************************
The second time I read a file (after the ds.Clear() I find that my
dt.Columns.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