Last post Jan 22, 2015 06:59 AM by Lokesh B R
Jan 22, 2015 06:47 AM|Junior1012|LINK
Please, can anyone give me idea or help me out how to solve this error.
Here is my sql query and backend that I use:
string username = HttpContext.Current.User.Identity.Name.ToString();
string password = newpassword.Text;
string query = "Update aspnet_Membership set aspnet_Membership.[Password] = '" + password + "' from aspnet_Membership join aspnet_Users"
+ "on aspnet_Membership.UserId = aspnet_Users.UserId where aspnet_users.UserName = '" + username + "'";
SqlCommand cmd = new SqlCommand(query, con1);
cmd.CommandType = CommandType.Text;
Thanks in advanced.
Jan 22, 2015 06:54 AM|AidyF|LINK
Use the Membership API to change passwords. Your code is negating all of the work Microsoft has done to make Membership secure.
Jan 22, 2015 06:59 AM|Lokesh B R|LINK
try this to change password.
// Update the password.
MembershipUser u = Membership.GetUser(User.Identity.Name);
if (u.ChangePassword(OldPasswordTextbox.Text, PasswordTextbox.Text))
Msg.Text = "Password changed.";
Msg.Text = "Password change failed. Please re-enter your values and try again.";
catch (Exception e)
Msg.Text = "An exception occurred: " + Server.HtmlEncode(e.Message) + ". Please re-enter your values and try again.";