Groups | Blog | Home
all groups > dotnet general > october 2004 >

dotnet general : how to insert only the New (Added) Rows with a SqlDataAdapter?


Mike McIntyre
10/15/2004 8:19:52 AM
Hi Piete,

This is done through the DataAdapter's Update call e.g.

custDA.Update(updTable.Select(Nothing, Nothing, DataViewRowState.Added))

Excellent advice and sample code is at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconupdatingdatabasewithdataadapterdataset.asp


--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
[quoted text, click to view]

DraguVaso
10/15/2004 5:01:10 PM
Hi,

I know there is some way to select only the new rows (and not the deleted,
changed etc) in a DataGrid, and insert them in the DataBase.

I want to do this by using a SqlDataAdapter.

Does anybody knwo how to doe this?

Thanks,

Pieter

DraguVaso
10/15/2004 5:12:13 PM
Thanks!
Unfortunately I'm using not a DataSet, only a DataTable, hehe :-/
Can you do something like this with only a DataTable too?

[quoted text, click to view]

DraguVaso
10/15/2004 5:13:57 PM
hehe ok I can do the same with a DataTable :-)
Thanks!
dtblGrid.GetChanges(DataRowState.Added)


[quoted text, click to view]

Cor Ligthert
10/15/2004 5:25:29 PM
Pieter,

Do not forget that the getchanges creates a copy of your dataset.
In this method you have to do an acceptchanges from your original
dataset/table after an succesful update.

I hope this helps?

Cor
"DraguVaso" <pietercoucke@hotmail.com> schreef in bericht
news:e99RzlssEHA.3372@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Shiva
10/15/2004 8:36:38 PM
Hi,
Use DataSet.GetChanges(DataRowState.Added) to get the new rows into a data
set. Then invoke SqlDataAdapter.Update() passing the new dataset.

Hope that helps.

[quoted text, click to view]
Hi,

I know there is some way to select only the new rows (and not the deleted,
changed etc) in a DataGrid, and insert them in the DataBase.

I want to do this by using a SqlDataAdapter.

Does anybody knwo how to doe this?

Thanks,

Pieter


AddThis Social Bookmark Button