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.
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".
zhshqzyc
Member
416 Points
517 Posts
Update username in asp.net membership provider
Apr 17, 2012 05:30 PM|LINK
Hello,
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?
Thanks.
bbcompent1
All-Star
33097 Points
8529 Posts
Moderator
Re: Update username in asp.net membership provider
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.
bbcompent1
All-Star
33097 Points
8529 Posts
Moderator
Re: Update username in asp.net membership provider
Apr 17, 2012 05:40 PM|LINK
take a look at this thread for more information: http://forums.asp.net/t/1167483.aspx/1
zhshqzyc
Member
416 Points
517 Posts
Re: Update username in asp.net membership provider
Apr 17, 2012 05:41 PM|LINK
I don't want to throw an error, just to prevent it.
How to modify the sql?
bbcompent1
All-Star
33097 Points
8529 Posts
Moderator
Re: Update username in asp.net membership provider
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".