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

  • Thread starter Thread starter DraguVaso
  • Start date Start date
D

DraguVaso

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
 
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.

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
 
Thanks!
Unfortunately I'm using not a DataSet, only a DataTable, hehe :-/
Can you do something like this with only a DataTable too?
 
hehe ok I can do the same with a DataTable :-)
Thanks!
dtblGrid.GetChanges(DataRowState.Added)
 
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
 
Back
Top