views:

62

answers:

1

Hi, How do I get the Record ID (Primary Key) immediately after saving a record? I have the ID column as auto generated. I need to pass the ID to another object as a "Foreign Key" before saving that object.

Currently I do

Product.Save()

Can't I do

int id = Product.Save()
+5  A: 

You can simply do

Product.Save();
int id = Product.ID; //or whatever your ID column is
Marek Karbarz