Start Free Trial
How do I get the UserId from aspnet_Users after CreateUser() to use as a foreign key in another Table?
I'm using 'CreateUser()' to insert a new user... but in the same event I want to retrieve the new created 'UserId' from 'aspnet_Users' and insert it into another table as a foreign key.
Microsoft SQL Server 2005
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I've been following a tutorial on
and the username doen't have to be unique. Is there any other way of doing it or do you think it'd best to make unique usernames a requirement?
I'm quite happy to set it so that a new member requires a unique user name but how do I do that?
When catching a 'MembershipCreateUserExcep
tion' one of the cases for an error message is as follows...
Name: return "There already exists a user with this username.";
This implies I can set the membership provider to only allow unique usernames. But all I can see in the Web.Config provider settings is...
but no requiresUniqueUserName option.
My mistake... somehow I have created to users with the same name but now it won't let me.
I can now user the Username in:
And it works!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
Plans and Pricing
Certified Expert Program
© 1996-2023 Experts Exchange, LLC. All rights reserved. Covered by US Patent