Get the Primary Key of a new Entry
-
05-07-2019 - |
Question
I have a number of child tables that have a foreign key to a parent table.
How do I add an entry in the parent table and get the primary key of that entry, so that I can then enter rows in the child tables that point to the entry in the parent table?
I'm doing this in a MS Access Database from a C# application.
OTHER TIPS
Try looking into the global variables that will give you the identity value. In SQL Server it is:
SELECT @@identity
Also look into the Scope_Identity() function
Should be able to SELECT @@IDENTITY even though you will have to use a second query to do so. I don't think MS Access will allow it to be combined into one query.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow