Hi NekoNao,
In ASP.Net to get the last inserted id from SQL Server you can go like this :-
1) Write a procedure to insert the records by passing parameter as all the values you want to insert to a specific table. Also declare an extra output parameter to get the last inserted record id to the table in that scope.
Ex :-
CREATE PROCEDURE [dbo].[SP_InsertTestData]
(
@Value1 VARCHAR(20)
, @Value2 VARCHAR(MAX)
, @Value3 VARCHAR(50) = ''
, @LastInsertedRecordID INT OUTPUT
)
AS
BEGIN
**********
END
2) You can get the last inserted record id using SCOPE_IDENTITY() method in SQL Server using just after the insertion operation then assign this value to the particular output parameter.
Ex:-
SET @LastInsertedRecordID = SCOPE_IDENTITY()
3) Now to get this ID in ADO.Net code and to set this value to a particular Label or TextBox is being explained here which might be further helpful for you.
Click Here[
^]
Hope this definitely of help to you.