I'm having some problems trying to input records into a relational database. The design is really simple but I'm running into a wall when it comes to having the foreign key from my child table autopopulate the primary key from the parent table. I've made the connections in Access and from what I understood, so long as I committed a transaction, the child table would populate the primary key from the parent table. This is not happening.

my question is: is there a method that would do what I'm looking for? or am I cornered into using @@IDENTITY and manually inserting the primary key into the child table?

I've tried using datasets and data adapters and created a datarelation within the dataset, but it is still not doing what I need. everything I've tried thus far has allowed me to insert records into multiple tables, but won't relate them because of the missing primary key in the child table.

what is the best practice to go about what I need to do?

Recommended Answers

All 2 Replies

Any luck with this? I am having a similar problem with connections to SQL

>but I'm running into a wall when it comes to having the foreign key from my child table autopopulate the primary key from the parent table.

No auto populate! You need to populate it manually.

Read "Retrieving Microsoft Access Autonumber Values" - article from MSDN.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.