i have done below code for change user password but their is no result and not working kindly help me to resolve this query....
i want to change password when user try to change password then first current password should be verify from the table...
my code is below....where i made mistake kindly help me ....
SqlConnection con = new SqlConnection(sqlCon);
con.Open();
string sqlSelect = "SELECT * FROM LOGIN_MASTER WHERE PASSWORD='"+ txtoldPassword.Text +"'";
SqlCommand cmd = new SqlCommand(sqlSelect, con);
//SqlDataAdapter sda = new SqlDataAdapter(cmd);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
//while (sdr.Read())
//{
if (sdr["PASSWORD"].ToString() == txtoldPassword.Text)
{
SqlConnection con2 = new SqlConnection(sqlCon);
con2.Open();
string updatePass = "UPDATE LOGIN_MASTER SET PASSWORD='" + txtconfPassword.Text + "' WHERE USERID='" + Session["uname"].ToString() + '";
SqlCommand cmd2 = new SqlCommand(updatePass, con);
SqlDataAdapter sda2 = new SqlDataAdapter(cmd2);
cmd2.ExecuteNonQuery();
lblmessage.Visible = true;
lblmessage.Text = "Password change successfully...";
con2.Close();
Session.RemoveAll();
Session.Abandon();
Response.Redirect("~/Sign_In");
Session.Clear();
}
else
{
lblmessage.Visible = true;
lblmessage.Text = "Old Password Not Matched, Re-enter currect old password";
txtoldPassword.Focus();
}
sdr.Close();
con.Close();
}
}