rowstate question

T

Tina

I'm manipulating a dataset in code by deleting and adding records. When I'm
done, the user has an opportunity to save or cancel the whole thing. If he
says Save, I delete everything in the database and now want to write this
dataset to the database.

In some cases some or all of the rows rowstate is unchanged so when I do a
da.update(ds) no update takes place. I want to change the rowstate to added
but it's readonly.

How can I get the database updated regardless of the value of rowstate?
thanks,
G
 
G

gani

tina,

i don't think deleting all your data is a good
idea at all (very risky actually). the Update method of
SqlDataAdapter is smart enough to determine which records
needs an update in the database.

HTH,
 
T

Tina

we have to fool the dataadaper because we are resequencing one of the key
fields. We have to (1) delete everything (2) replace eveything.
 
M

Miha Markic [MVP C#]

Hi Tina,

Tina said:
I'm manipulating a dataset in code by deleting and adding records. When I'm
done, the user has an opportunity to save or cancel the whole thing. If he
says Save, I delete everything in the database and now want to write this
dataset to the database.

I won't even question you about this practice :)
In some cases some or all of the rows rowstate is unchanged so when I do a
da.update(ds) no update takes place. I want to change the rowstate to added
but it's readonly.

How can I get the database updated regardless of the value of rowstate?
thanks,

You might create a copy of dataset's structure and then copy rows into it
(perhaps using LoadDataRow method).
The rows will have RowState.Added.
 

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