[Solved] why my password isn’t changed?


this part:

cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
cmd.Dispose();
cmd = null;
db.Close();
db.Open();
SqlDataReader DR;
DR = cmd.ExecuteReader();

why do you execute a non query, which is a query (select * from …)?
why do you dispose the SqlCommand object cmd and why do you reuse it after disposing?
why do you close and open the line below?

I would rewrite those lines it like this:

SqlDataReader DR = cmd.ExecuteReader();

I would recomment a using statement or closing the connection in a finally block:

SqlConnection db = new SqlConnection(strcon);
try{
    db.Open();
    //.... the rest
}
catch(Exception ex)
{
    ShowPopUpMsg("unable to connect database: " + ex.Message);
}
finally
{
    db.Close();
}

and another thing: I would use the primary key in the update statement. where id = login_id instead of the username. unless the username is set to “unique”

0

solved why my password isn’t changed?