Table Adapter, set foreign key fields on child tables...

I have 3 tables in a relational database (SQL2005). Lets call them TableA, TableB and TableC. Each tables has an auto inc PK. TableA has a 1 to many relation to TableB which has a 1 to many relation to TableC.
Of these tables I create a dataset in VS2005 using TableAdapters. The update and select statements are made of SQL, not StoredProcedures.
I fill the TableB & TableC with a custom made Fill Methods and because of the Fill returns zero rows I add rows to the tables by adding new rows to the dataset tables TableB & TableC. I then get the Added rows using a (ADO)Select method on the dataset tables where Row State = Added. I then update the database by calling the dataset.table.update for these added rows in TableB and expect the AcceptChanges method to put the correct FK field values read from the database into the child table(TableC); The Accept/Reject Rule on the TableB relation to TableC is set to Cascade along with the Update Rule too.
It must be said that TableA also have a FK constraint to TableC, but as long as only the relation between them are created in the dataset xsd file I thought that was ok.

I know that the rows are added okto the dataset tables. But after calling the first update method for TableB, which inserts the rows to the datbase, no rows willbe added for TableC when that update method is called.


Thankful for any help.

Harald

[1427 byte] By [HaraldStensrud] at [2007-12-24]

.NET Development

Site Classified