nvs_victor
asked on
What is the ASP.NET method that retrieves the lastly inserted primary key?
Hi experts!
I want to use this function:
WebSecurity.CreateUserAndA ccount(Use r_Profile, username,n ull,false) ;
It creates a record in the User_Profile table and in the webpages_Membership.
But I also need to create a record in another table using the id recently inserted.
How do I do this?
stackoverflow.com/question s/9477502/ get-the-la st-inserte d-row-id-w ith-sql-st atement
But it doesn’t apply here because I don’t have access to the procedure of WebSecurity.CreateUserAndA ccount()
I remember seeing a page of ASP.NET methods on the ASP.NET website's learning section, in which one method allows me to retrieve the last inserted ID, but I can’t find it.
Anyone know what method it is that does this? Or an alternative way?
Thanks!
I want to use this function:
WebSecurity.CreateUserAndA
It creates a record in the User_Profile table and in the webpages_Membership.
But I also need to create a record in another table using the id recently inserted.
How do I do this?
stackoverflow.com/question
But it doesn’t apply here because I don’t have access to the procedure of WebSecurity.CreateUserAndA
I remember seeing a page of ASP.NET methods on the ASP.NET website's learning section, in which one method allows me to retrieve the last inserted ID, but I can’t find it.
Anyone know what method it is that does this? Or an alternative way?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I hope the points awarded make sense. Thanks a lot!
ASKER
first, thank you all for helping!
@carl_tawn,
Thank you! I think this would be a great solution to my problem. The userName is unique, so it'll work well.
@mark_wills,
Thank you for taking the time to help! I apologize because I mixed up two different method parameters into one by mistake when posting on EE (though I have it correct in my code).
The correct parameters for the method is indeed this:
WebSecurity.CreateUserAndA
Yes, based on carl_tawn's approach, I can do it either way, both an inline SQL select statement or an ASP.NET method that carl_tawn pointed out, since the userName is unique.
Also thank you for so much for your very polite response, despite my mistake! :)
Closing the question, thanks!