I am using ASP.NET, C#, and SQL Server 2012.
I have a button that will insert into a new row in a table called images, and I am using an identity to generate a new integer id for the image_id.
I also have other tables with the image_id as a foreign key.
What I want is to store the value of the newly generated image_id in a variable and use it later with other functions.
I can't use the last row value since I will use the table with other buttons and if they clicked at the same time they might get the other's data.
Is there a way to save the exact id of the newly inserted row in a variable?