By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Updating database with changes in dataset

P: n/a
Hello all, I've made a dataset by using the xsd tool in C#. In the xsd
schema, there are a few tables, each has its own primary key. And, I've made
relation between them.

After all things are done, I can use the dataset class generated to retrieve
data. The problem is that, when I try to delete a parent row (using
RemoveTABLERow method), both the parent and child tables rowcount decrease as
expected. But only the changes done in child table can be updated to the DB.
The parent row is still there.

I've tried the sequence suggested by MSDN:
1. Child table: delete records.
2. Parent table: insert, update, and delete records.
3. Child table: insert and update records.

Sometimes nothing changed in DB. Sometimes only child table show changes.

Could anyone give me any hint what I should do to fix the situation?
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

Can you please post some code? Meanwhile, please make sure you properly
configure Insert/Update/DeleteCommands on all of the data adapters and that
you never call AcceptChanges before calling Update() on the data adapters.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Kenny" <Ke***@discussions.microsoft.com> wrote in message
news:99**********************************@microsof t.com...
Hello all, I've made a dataset by using the xsd tool in C#. In the xsd
schema, there are a few tables, each has its own primary key. And, I've
made
relation between them.

After all things are done, I can use the dataset class generated to
retrieve
data. The problem is that, when I try to delete a parent row (using
RemoveTABLERow method), both the parent and child tables rowcount decrease
as
expected. But only the changes done in child table can be updated to the
DB.
The parent row is still there.

I've tried the sequence suggested by MSDN:
1. Child table: delete records.
2. Parent table: insert, update, and delete records.
3. Child table: insert and update records.

Sometimes nothing changed in DB. Sometimes only child table show changes.

Could anyone give me any hint what I should do to fix the situation?


Nov 17 '05 #2

P: n/a
Thx much, Dmytro.

I realized that I've used the wrong function to delete the row in my
dataset. Now I can do what I want.

However, if I load data from more than 10 tables (say, a few rows per
table), all are linked up by parent-child relations. My update functions must
be arranged very carefully in a particular order (Child table row deletion
first...). Is that correct?

Are there any easier way to deal with updating the DB?

Thanks again.

"Dmytro Lapshyn [MVP]" wrote:
Hi,

Can you please post some code? Meanwhile, please make sure you properly
configure Insert/Update/DeleteCommands on all of the data adapters and that
you never call AcceptChanges before calling Update() on the data adapters.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"Kenny" <Ke***@discussions.microsoft.com> wrote in message
news:99**********************************@microsof t.com...
Hello all, I've made a dataset by using the xsd tool in C#. In the xsd
schema, there are a few tables, each has its own primary key. And, I've
made
relation between them.

After all things are done, I can use the dataset class generated to
retrieve
data. The problem is that, when I try to delete a parent row (using
RemoveTABLERow method), both the parent and child tables rowcount decrease
as
expected. But only the changes done in child table can be updated to the
DB.
The parent row is still there.

I've tried the sequence suggested by MSDN:
1. Child table: delete records.
2. Parent table: insert, update, and delete records.
3. Child table: insert and update records.

Sometimes nothing changed in DB. Sometimes only child table show changes.

Could anyone give me any hint what I should do to fix the situation?


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.