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

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
 
S

Shiva

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
 
D

DraguVaso

Thanks!
Unfortunately I'm using not a DataSet, only a DataTable, hehe :-/
Can you do something like this with only a DataTable too?
 
D

DraguVaso

hehe ok I can do the same with a DataTable :)
Thanks!
dtblGrid.GetChanges(DataRowState.Added)
 
C

Cor Ligthert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top