Re: Dataset not Clearing



Hello tshad,

Seems that it's code optimization :)
Try to trace the dataSet content after clearing it in release mode. Because I assume that in debug it just don't clear it when u ask and keep it till u either override it or exit the function

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it" (c) Michelangelo


t> I am trying to clear my dataset each time I read a new csv file but
t> it seems to keep the data from the previous time.
t> t> If I do:
t> *********************************************************************
t> ***********
t> foreach (string strFile in strFiles)
t> {
t> ds.Clear();
t> da = new OleDbDataAdapter("SELECT * FROM " +
t> Path.GetFileName(strFile),csvConnection);
t> da.Fill(ds);
t> foreach (DataTable dt in ds.Tables)
t> {
t> for (int i=0;i<dt.Columns.Count-1;i++)
t> {
t> switch(i)
t> {
t> case 0:
t> formName = dt.Columns[i].ColumnName.Replace("Form ","");
t> dt.Columns[i].ColumnName = "FieldName";
t> break;
t> *********************************************************************
t> ************
t> The second time I read a file (after the ds.Clear();) I find that my
t> dt.Columns[i].ColumnName will be equal to "FieldName", which is what
t> I change the column to the first time around!!!
t> t> Why is that?
t> t> It should be what is in the first row, first column of the table,
t> since I wiped out the table. If not, how do I get it to work
t> correctly?
t> t> Thanks,
t> t> Tom
t>


.



Relevant Pages

  • Dataset not Clearing
    ... I am trying to clear my dataset each time I read a new csv file but it seems ... foreach (string strFile in strFiles) ... It should be what is in the first row, first column of the table, since I ...
    (microsoft.public.dotnet.framework.aspnet)
  • Calculating Column Averages from a CSV File
    ... I am trying to calculate column averages (excluding 0's) for all the ... columns in a CSV file except the first column. ... perl code, perl is calculating the 2nd column's average 9 times rather ...
    (perl.beginners)
  • Re: Import CSV file
    ... When I try to import a CSV file (downloaded from Etrade), ... in the first column with the commas intact. ... I tried saving it as an Excel CSV file and re-importing. ...
    (microsoft.public.mac.office.excel)
  • Re: When I open a *.CSV file, text appear in the first column? What c.
    ... When I open in Excel 2003 a CSV file, the text appear in the first column. ... Prev by Date: ...
    (microsoft.public.excel.setup)
  • Re: Connections when reading excel into dataset
    ... This is how I would do it with a csv file. ... foreach (string strFile in strFiles) ... Same question - do I have to close the Connection after each da.Fill. ... OleDbConnection xlsConnection = new ...
    (microsoft.public.dotnet.languages.csharp)