Re: Dataset not Clearing
- From: Michael Nemtsev [MVP] <nemtsev@xxxxxxx>
- Date: Tue, 12 Feb 2008 10:51:22 +0000 (UTC)
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>
.
- Follow-Ups:
- Re: Dataset not Clearing
- From: tshad
- Re: Dataset not Clearing
- References:
- Dataset not Clearing
- From: tshad
- Dataset not Clearing
- Prev by Date: Re: JavaScript and Components on Pages
- Next by Date: Re: File Upload
- Previous by thread: Dataset not Clearing
- Next by thread: Re: Dataset not Clearing
- Index(es):
Relevant Pages
|