PC Review


Reply
Thread Tools Rate Thread

DataSet.Clear()

 
 
mick
Guest
Posts: n/a
 
      8th Oct 2009
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

 
Reply With Quote
 
 
 
 
Miha Markic
Guest
Posts: n/a
 
      9th Oct 2009
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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


 
Reply With Quote
 
mick
Guest
Posts: n/a
 
      9th Oct 2009

"Miha Markic" <miha at rthand com> wrote in message
news:F39C4D09-1AA5-45F1-BE03-(E-Mail Removed)...
> 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


 
Reply With Quote
 
Miha Markic
Guest
Posts: n/a
 
      9th Oct 2009

> 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

 
Reply With Quote
 
mick
Guest
Posts: n/a
 
      10th Oct 2009

"Miha Markic" <miha at rthand com> wrote in message
news:F5B8AF6B-99BD-4D30-ABEE-(E-Mail Removed)...
>
>> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xmldatadocument.dataset. how to perform a clear on the dataset? BobC Microsoft ADO .NET 0 31st Jan 2007 05:17 PM
Re: does DataSet.ReadXml() clear current table information on DataSet CrunkByte Microsoft Dot NET Framework 0 21st May 2005 03:11 AM
Re: dataset.clear doesn't clear listbox Val Mazur Microsoft ADO .NET 2 11th Nov 2004 03:12 AM
Difference between DataSet.Clear and DataSet.Reset? Bill Todd Microsoft ADO .NET 6 19th Mar 2004 09:54 AM
Does Dataset.Tbl.Clear() clear all tables or One? Daryll Shatz Microsoft ADO .NET 3 29th Oct 2003 06:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 AM.