Autonumber and linking in Datasets

csharp_boy

Member
Joined
Feb 5, 2006
Messages
5
Hi

Say i have two tables in Access

Order and Order_Items where Order is the parent and Order_Item is the child and it is linked by the columns order_ID.

order_ID in the Order table is the primary key and done by autonumbering whilst order_ID in the Order_Items is a foreign key.

my problem is this. i have both tables and schemas put onto a dataset, where i create new rows, but i do not assign an order_ID for any of the rows i create because Access would autonumber them when i call an Update.

The problem is that how do i link Order_Items record with Order record in the dataset? would i have to update the database every time i create an Order record in order to get assigned an order_id before i can then create child items in the Order_Item table that link to this order_ID or is there some sort of feature in ADO.NET that allow you to link two records together without having to assign a value to the linking columns?

Thanks.
 
I use negative indexes for records that are added while disconnected from the database. That way you ensure that you are not duplicating existing indexes, while still giving your disconnected records a unique index. When you call Update, the indexes will be updated to whatever you set up in the database.

Hope that makes sense. Let me know if it doesnt.

Todd
 
Back
Top