Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the Primary Key of a new Entry

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.

like image 254
Robert Avatar asked Oct 07 '08 20:10

Robert


2 Answers

Microsoft Access 2000 or later does support the @@IDENTITY property to retrieve the value of an Autonumber field after an INSERT. (msdn)

Edit: This is the link to a similar article for .NET 3.5

like image 114
Instantsoup Avatar answered Sep 30 '22 19:09

Instantsoup


Getting the identity of the most recently added record

like image 27
Pavel Chuchuva Avatar answered Sep 30 '22 19:09

Pavel Chuchuva