problem changing username, PART 2

J

Jeff

hi

asp.net 3.5

Below is my code for changing username and password of a user.
The problem is that I can make only 1 change. I mean I can once make a
change to username or password, or both. But the second time I make a change
the user will not be able to login

any suggestions?

ProfileCommon userProfile = GetProfileBySaleId(salgsid);
if (userProfile != null)
{
user.ChangePassword(userProfile.Postal.Code, postalcode);
if (Membership.ValidateUser(username, postalcode))
FormsAuthentication.RedirectFromLoginPage(username, true);
else
{
//okay, changing password wasn't enough, then the
//username need to be changed
try
{
string connstr =
ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString();
using (SqlConnection cn = new SqlConnection(connstr))
{
SqlCommand cmd = new SqlCommand("ah_Updateuser", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@newname", SqlDbType.NVarChar).Value =
username;
cmd.Parameters.Add("@oldname", SqlDbType.NVarChar).Value =
userProfile.UserName;
cn.Open();
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
if (Membership.ValidateUser(username, postalcode))
FormsAuthentication.RedirectFromLoginPage(username, true);

}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top