473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 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[i].ColumnName.Replace("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

Feb 12 '08 #1
0 752

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dan | last post by:
I have a C# form with an OleDBconnection, adaptor and dataset along with a several text boxes linked to the Dataset and 2 buttons. I am assigning the dataset to a DataGrid. My problem: I enter...
3
by: Mojtaba Faridzad | last post by:
Hi, I am a newbie! I am wondering how DataSet keeps the data. I am using MySQL as database engine. when I use "Fill" method to set a table in DataSet, does C# retreive all data (base on Select...
3
by: Brad | last post by:
I'm working with a DataGrid in C#, and the user needs to be able add and remove columns from the DataGrid on the fly, without opening and closing the form. The scenario is this. I have a setup...
7
by: Paul King | last post by:
I have created a form on the web that allows us to update a table on our SQL server using the INSERT function. The way the page is constructed is that the results panel refreshes with the new...
0
by: PD | last post by:
I am trying to stream out a PDF file via the response object and when I execute the code it always brings up the first document that I pulled up.Even when I step through the code, I can see the new...
5
by: Nita | last post by:
Hi, Im a sort of newbie when it comes to VB.NET, so forgive me if this is a simple question. I have a dataset i wish to clear, ive used a parameterised stored procedure from MS Access. Currently...
0
by: Hubert | last post by:
Hi I created XmlDataDocument synchronized with DataSet. everythingi is grat until I need to clear all data from it. I've tried Reset(), Clear(), RemoveChild etc. but nothing works. The only way I...
3
by: Cub71 | last post by:
Is it possible to use dataset.Clear(); dataAdapterSomething.Update(dataset.table); to clear a table in an SQL database? I am not able to get this to work. The dataset clears, but the...
0
by: Chris | last post by:
Hello, I have a problem with re-loading datasets. As a simple example, if I have an SQL table of addresses comprising active and inactive addresss, I wish to load either sub-set by clicking on...
1
by: sweetiecakes | last post by:
Hi I have a ListBox which is binded to a dataSet. When I need to refresh this dataSet, it works, but the old entries don't get removed from the listbox. Items.Clear() doesn't work when a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.