PC Review


Reply
Thread Tools Rate Thread

Data Adapter Update Method

 
 
Yossi And Inbar
Guest
Posts: n/a
 
      12th Dec 2005
Hi,

I am using SqlDataAdapter and i want to do just the delete update
to delete child table and after that i want to do the InsertCommand and
etc...
So how can i choose to do Insert Or Update or Delete not with
DataAdapter.Update method..

Thanks,
Yossi


 
Reply With Quote
 
 
 
 
W.G. Ryan - MVP
Guest
Posts: n/a
 
      12th Dec 2005
Yossi - I'm not sure I understand your question but let me take a stab at
it. When you call Update, the adapter looks row by row at the rowstate of
each given row and then uses the respective command for that rowstate (ie,
DeleteCommand for Deleted, Insert for Added and Update for Modified). If
you have two tables, then you need to Adapters, one for the child and one
for the parent. If you don't want to use the Update method, then you should
create your own commands and then iterate through the table, use your own
code to determine which rows you want to delete or update, and then call
your own Sql Command or Stored Procedure, passing in the relevant values for
that row. If you do this, you don't need a DataAdatper or Table Adatper, you
can just use ExecutenonQuery to accomplish what you need.

Does this answer your question? If not, please tell me a little more about
it and I'll do my best to answer it.

Cheers,

Bill
"Yossi And Inbar" <(E-Mail Removed)> wrote in message
news:u0aAg80$(E-Mail Removed)...
> Hi,
>
> I am using SqlDataAdapter and i want to do just the delete update
> to delete child table and after that i want to do the InsertCommand and
> etc...
> So how can i choose to do Insert Or Update or Delete not with
> DataAdapter.Update method..
>
> Thanks,
> Yossi
>



 
Reply With Quote
 
Stephen Ahn
Guest
Posts: n/a
 
      14th Dec 2005
Use DataSet.GetChanges(DataRowState) to get a subset of what you want to
update, then call DataAdapter.Update on that subset.
eg.

// do deletions
DataSet subsetds = YourDataSet.GetChanges(DataRowState.Deleted);
YourDataAdapter.Update(subsetds);

// do insertions
subsetds = YourDataSet.GetChanges(DataRowState.Added);
YourDataAdapter.Update(subsetds);

// do modifications
subsetds = YourDataSet.GetChanges(DataRowState.Modified);
YourDataAdapter.Update(subsetds);

HTH,
Stephen

"Yossi And Inbar" <(E-Mail Removed)> wrote in message
news:u0aAg80$(E-Mail Removed)...
> Hi,
>
> I am using SqlDataAdapter and i want to do just the delete update
> to delete child table and after that i want to do the InsertCommand and
> etc...
> So how can i choose to do Insert Or Update or Delete not with
> DataAdapter.Update method..
>
> Thanks,
> Yossi
>



 
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
Table Adapter Update Method Mohamed Shafiee Microsoft VB .NET 6 19th Oct 2006 08:00 AM
No .Fill Method in Data Adapter =?Utf-8?B?ZGN1ZmY=?= Microsoft Dot NET Compact Framework 10 16th Nov 2005 07:12 AM
SqlClient Data Adapter Fill Method =?Utf-8?B?cHRheWxvcg==?= Microsoft ADO .NET 5 10th Aug 2005 06:25 PM
Re: Data Adapter Update method William Ryan eMVP Microsoft ADO .NET 0 3rd Mar 2004 10:03 PM
Using Data adapter's Update method Marina Microsoft ADO .NET 5 11th Dec 2003 04:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:52 PM.