Main Page | Report this Page
.NET DotNet Forum Index  »  ADO .NET Forum  »  DataSet.Clear()...
Page 1 of 1    

DataSet.Clear()...

Author Message
mick...
Posted: Thu Oct 08, 2009 4:44 pm
Guest
I`ve been trying to get to know ADO.net lately and I wonder if anyone can
explain why the following does not work -

myDataSet.Clear();
myDataSet.AcceptChanges();
myTableAdapter.Update(myDataSet);

If you clear the dataset and then do the update shouldnt the database be
cleared as well. When I tried this the contents of the database are still
there when I rerun my app.

What I ended up doing was iterating throw the dataset and deleting row by
row but I`m curious why the above doesnt work.

TIA,

mick
 
Miha Markic...
Posted: Fri Oct 09, 2009 1:52 am
Guest
In your case Clear removes all the information from *Dataset* thus Update
won't do anything. Update does its things based on the rows in their
RowState.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com


"mick" <coughcough at (no spam) privacy.com> wrote in message
news:#ttrYjGSKHA.4592 at (no spam) TK2MSFTNGP06.phx.gbl...
Quote:
I`ve been trying to get to know ADO.net lately and I wonder if anyone can
explain why the following does not work -

myDataSet.Clear();
myDataSet.AcceptChanges();
myTableAdapter.Update(myDataSet);

If you clear the dataset and then do the update shouldnt the database be
cleared as well. When I tried this the contents of the database are still
there when I rerun my app.

What I ended up doing was iterating throw the dataset and deleting row by
row but I`m curious why the above doesnt work.

TIA,

mick
 
mick...
Posted: Fri Oct 09, 2009 8:37 am
Guest
"Miha Markic" <miha at rthand com> wrote in message
news:F39C4D09-1AA5-45F1-BE03-B1288183D639 at (no spam) microsoft.com...
Quote:
In your case Clear removes all the information from *Dataset* thus Update
won't do anything. Update does its things based on the rows in their
RowState.


I`ve been reading a bit more and would just like you confirm that I
understand it correctly -

When I use Clear on the DataSet it actually clears all of the entries but if
I use Delete it just "marks" entries for deletion but does not actually
perform any deletion until the update. Is this correct?

mick
 
Miha Markic...
Posted: Fri Oct 09, 2009 12:00 pm
Guest
Quote:
I`ve been reading a bit more and would just like you confirm that I
understand it correctly -

When I use Clear on the DataSet it actually clears all of the entries but
if I use Delete it just "marks" entries for deletion but does not actually
perform any deletion until the update. Is this correct?

Yes, it will mark existing rows with RowState = Deleted. If the row doesn't
exist in database (it has been added in memory) it will be removed.

HTH,
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: blog.rthand.com
 
mick...
Posted: Fri Oct 09, 2009 8:49 pm
Guest
"Miha Markic" <miha at rthand com> wrote in message
news:F5B8AF6B-99BD-4D30-ABEE-FBEF503C015F at (no spam) microsoft.com...
Quote:

I`ve been reading a bit more and would just like you confirm that I
understand it correctly -

When I use Clear on the DataSet it actually clears all of the entries but
if I use Delete it just "marks" entries for deletion but does not
actually perform any deletion until the update. Is this correct?

Yes, it will mark existing rows with RowState = Deleted. If the row
doesn't exist in database (it has been added in memory) it will be
removed.

Thanks Miha.

mick
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Fri Dec 04, 2009 5:03 pm