i used this code for change my current password and i whant to change my current user name and password.thanks
Change password code(DATA LAYER)
public int DLChangePassword(string UserName, string Oldpwd)
{
con.Open();
SqlCommand cmd;
String sql = "SELECT * FROM tbluser WHERE UserName=@UserName AND Password = @Password";
cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@UserName", UserName);
cmd.Parameters.AddWithValue("@Password", Oldpwd);
SqlDataReader reader = cmd.ExecuteReader();
if (reader != null && reader.HasRows)
{
con.Close();
return 1;
}
else
{
con.Close();
return 0;
}
}
public string Update(string UserName, string Newpwd)
{
con.Open();
string str = "Update tbluser set Password=@Password where AdminName=@AdminName";
SqlCommand cmd = new SqlCommand(str, con);
cmd.Parameters.AddWithValue("@AdminName", UserName);
cmd.Parameters.AddWithValue("@Password", Newpwd);
cmd.ExecuteNonQuery();
con.Close();
return "success full change";
}
Change password(BL code)
public int BLChangePassword(string UserName, string Oldpwd)
{
return obj.DLChangePassword(UserName, Oldpwd);
}
public string BLupdate(string UserName, string Newpwd)
{
return obj.Update(UserName, Newpwd);
}
Change password(LOGIN.ASPX.CS)
protected void btnChangePwd_Click(object sender, EventArgs e)
{
clsBLayer obj = new clsBLayer();
if (txtCurentPwd.Text != txtCurentPwd.Text)
{
lblMsg.Text = "Retype Password Miss-match Try Agan";
txtCurentPwd.Text = txtNewPwd.Text= "";
}
else
{
int a = (int)obj.BLChangePassword(txtCurentUserName.Text, txtNewPwd.Text);
if (a != 0)
{
lblMsg.Text = obj.BLupdate(txtCurentUserName.Text, txtNewPwd.Text);
txtCurentPwd.Text = txtReptPwd.Text = txtNewPwd.Text = "";
}
else
{
lblMsg.Text = "User And Password not Exist";
}
}
}
Thanks to all of you.