Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 18, 2012 11:54 AM by bbcompent1
Apr 17, 2012 05:30 PM|LINK
I want to update the username? How to do it? I know that we can simply using updata command but how can we prevent duplicate username?
Apr 17, 2012 05:38 PM|LINK
In your code behind, you take the textbox1.text and do a query to see if a user with that name exists. If not, update the username, if it does, throw an error.
Apr 17, 2012 05:40 PM|LINK
take a look at this thread for more information:
Apr 17, 2012 05:41 PM|LINK
I don't want to throw an error, just to prevent it.
How to modify the sql?
UPDATE aspnet_Users SET UserName=@NewUsername,LoweredUserName=@LoweredNewUsername WHERE UserName=@OldUsername
Apr 18, 2012 11:54 AM|LINK
But that's a problem because if you don't catch the duplication in sql, the user won't know the name is already taken. You can simply use label text to say "That name already exists, please try again".