PC Review


Reply
Thread Tools Rate Thread

Re: Update from Datasource to the database with sqlDataAdapter

 
 
Pete Wright
Guest
Posts: n/a
 
      22nd May 2004
Without seeing the code it's very hard to comment. One thing worth checking
though is how you are 'deleteing' rows in the cached datatable. You should
be calling Datarow.delete on the row in question. This will flag the row as
deleted enabled the dataadapter to detect which rows have been deleted and
run the appropriate database delete command.

In order for the data adapter to delete though you will also need to have
some mapping going on between the datarow's original primary key and the
table's primary key in the database. Do you have this in place as well ?

Regards


--
--------------------------------------------------------
Peter Wright (www.petewright.org)
Author of ADO.NET Novice To Pro

From Apress. www.apress.com

"Ori Anavim via .NET 247" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> Hi,
>
> I have a listbox which is bounded to a datatable. I allow the users to

add/remove items from the list while adding/remove rows from the datatable
which function as the datasource.
>
> When I come to do the ?update? back to the datatbase using the

SqlDataAdapter and the insert/delete command, I see that only the new rows
are added and the old one doesn?t. removed from the database.
>
> After a short investigation, I notice that if I remove the rows directly

from the datatable the deletecommand doesn?t have a row to operate on.
>
> Can someone explain me exactly how to use the delete command along with a

binding to a listbox which you can remove and add items.
>
> Thanks,
>
> Ori.
>
>
> --------------------------------
> From: Ori Anavim
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>6Z0phwcpukajpwngCx+Jyw==</Id>



 
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
Update more than 1 table in a DataSet using SqlDataAdapter.Update LP Microsoft VB .NET 3 13th Feb 2005 05:49 PM
Update more than 1 table in a DataSet using SqlDataAdapter.Update LP Microsoft ADO .NET 3 13th Feb 2005 05:49 PM
Re: Update from Datasource to the database with sqlDataAdapter William Ryan eMVP Microsoft ADO .NET 0 22nd May 2004 10:21 PM
How to update the Database by using SqlDataAdapter object in asp.net? zhaoJian Microsoft ASP .NET 0 6th Nov 2003 04:06 AM
SqlDataAdapter.Update doesn't delete, will however insert and update, what gives? Andy Baldwin Microsoft ADO .NET 1 22nd Oct 2003 08:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:02 PM.