SqlDataAdapter.Update and DataSets

G

Guest

I have a DataSet that I populated with an SqlDataAdapter with a SelectCommand.

Once I have the DataSet I insert some new rows, delete some other rows, and
update some existing rows.

I would like to process the "inserts" only at a specific time. The
SqlDataAdpter.Update peforms all of the operations (Insert,Update,Delete). If
I do not specify UpdateCommand and DeleteCommand then I get an exception.

Is there a way to only do the inserts and then only do the deletes and then
only do the updates? I have no control of how the DataSet is manipulated so I
can not prohibit receiving a DataSet that has all three types of operations.

Thank you.
 
C

cpnet

Couldn't you use

yourDataAdapter.Update( yourDataTable.Select("","",
DataViewRowState.Added));

From my reading of the help info, that should update just the rows that have
been added - in other words, it will just do the inserts. You could take
the same approach for the Updates and the Deletes.
 
E

Earl

That's interesting. I rarely submit all 3 at the same time, and usually only
submit one or the other. Show a piece of your DataAdapter update code and
someone here can help.
 
G

Guest

Thank you. That looks like the path I need. I am new and was looking for the
functionality in the Adapter instead of the Table. Thanks. This will help
tremendously.
 
G

Guest

The model will be that a dataset is returned to some client or domain layer.
Those layers are not restrained in their usage of a dataset. I can not assume
anything.

The previous response suggests using the DataTable's select statement and
use the DataViewRowState. I think this will do the job.

Thanks.
 

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