D
David Adams
Hi,
I am having a big problem with trying to update a strongly typed dataset
with multiple tables and datarelations. Here is the basic schema:
Table: Application
APP_ID (PK)
ADDRESS
CITY
Table: FamilyMembers
FM_ID (PK)
APP_ID (FK)
NAME
Table: Education
ED_ID (PK)
APP_ID (FK)
FM_ID (FK)
SCHOOL
Table: Jobs
JB_ID (PK)
APP_ID (FK)
FM_ID (FK)
JOB
The Application table is the parent with three child tables, FamilyMembers,
Education, and Job. The FamilyMembers table is the parent of the Education
and Job tables as well. I have 3 datarelations set on App_ID with the
parent Application, and 2 datarelations set on FM_ID with the parent
FamilyMembers. Each datarelation has an Update/Delete rule set to "Cascade"
and a Accept/Reject rule set to "None". Each primary key value has an
autoincrement of -1 with a start of -1. The identity values from the
database update the temporary primary key values on an update.
I am peroforming the following dataadapter update actions:
adp1.Update(ds.Application)
adp2.Update(ds.FamilyMembers)
adp3.Update(ds.Application)
adp4.Update(ds.Jobs)
The order is important so that the newly updated primary key values cascade
to the children. The first update cascades the APP_ID perfectly. Each of
the 4 tables will show the new APP_ID returned after the
adp1.Update(ds.Application) line. However, when I step through the code
after the adp2.Update(ds.FamilyMembers) line, the FM_ID cascades to the
Education table, but the Jobs table does not cascade: the temporary value
from the autoincrement is still there.
A few interesting notes:
When I step through the code, immediately prior to the
adp2.Update(ds.FamilyMembers) line, I can see the related FamilyMembers row
(ds.Jobs[0].FamilyMembersRow). But when execute the adp2.Update line, the
related FamilyMembers row is set to "undefined value", as if the relation
has been removed temporarily. The datarelation still exists. However, the
related parent row is null.
When I remove the datarelation between FamilyMembers and Education, the
FM_ID cascades to the Jobs table just fine.
------------
If anyone could provide some insight as to why the Jobs table does not
receive the cascading update to the FM_ID, I would really appreciate it.
Thanks!
Dave
I am having a big problem with trying to update a strongly typed dataset
with multiple tables and datarelations. Here is the basic schema:
Table: Application
APP_ID (PK)
ADDRESS
CITY
Table: FamilyMembers
FM_ID (PK)
APP_ID (FK)
NAME
Table: Education
ED_ID (PK)
APP_ID (FK)
FM_ID (FK)
SCHOOL
Table: Jobs
JB_ID (PK)
APP_ID (FK)
FM_ID (FK)
JOB
The Application table is the parent with three child tables, FamilyMembers,
Education, and Job. The FamilyMembers table is the parent of the Education
and Job tables as well. I have 3 datarelations set on App_ID with the
parent Application, and 2 datarelations set on FM_ID with the parent
FamilyMembers. Each datarelation has an Update/Delete rule set to "Cascade"
and a Accept/Reject rule set to "None". Each primary key value has an
autoincrement of -1 with a start of -1. The identity values from the
database update the temporary primary key values on an update.
I am peroforming the following dataadapter update actions:
adp1.Update(ds.Application)
adp2.Update(ds.FamilyMembers)
adp3.Update(ds.Application)
adp4.Update(ds.Jobs)
The order is important so that the newly updated primary key values cascade
to the children. The first update cascades the APP_ID perfectly. Each of
the 4 tables will show the new APP_ID returned after the
adp1.Update(ds.Application) line. However, when I step through the code
after the adp2.Update(ds.FamilyMembers) line, the FM_ID cascades to the
Education table, but the Jobs table does not cascade: the temporary value
from the autoincrement is still there.
A few interesting notes:
When I step through the code, immediately prior to the
adp2.Update(ds.FamilyMembers) line, I can see the related FamilyMembers row
(ds.Jobs[0].FamilyMembersRow). But when execute the adp2.Update line, the
related FamilyMembers row is set to "undefined value", as if the relation
has been removed temporarily. The datarelation still exists. However, the
related parent row is null.
When I remove the datarelation between FamilyMembers and Education, the
FM_ID cascades to the Jobs table just fine.
------------
If anyone could provide some insight as to why the Jobs table does not
receive the cascading update to the FM_ID, I would really appreciate it.
Thanks!
Dave