change password in asp.net [Resolved]

Posted by Ankitsrist under ASP.NET on 12/16/2012 | Points: 10 | Views : 1239 | Status : [Member] | Replies : 6
hello
i have update password aspx page where i used dropdownlist which shows all the users...and three textboxes which takes old password and new nd confirm passwrd....but problem is it is not updating password....my code is as follows.....

protected void Button1_Click(object sender, EventArgs e)
{
db.myconnection();
try
{

if (TextBox2.Text == TextBox3.Text)
{
db.myconnection();
SqlCommand cmd = new SqlCommand("update login set password='" + TextBox2.Text + "', where username='" + DropDownList1.SelectedItem.Text+ "'", db.sqlcon);
cmd.ExecuteNonQuery();
Label2.Text = "Password Updated Successfully";

}
}

catch (Exception r){

Response.Write("updation failed");
}

}

please help




Responses

Posted by: Ankitsrist on: 12/17/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
rajnkanth sir one more thing i found 'if' block is not working means...i checked it by using respnse.write("updation failed") in catch block and when i run my application and click button catch block execute

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Somu475 on: 12/16/2012 [Member] Starter | Points: 25

Up
0
Down
Change the following bit of thing in ur query and try.

where username='" + DropDownList1.SelectedValue + "'"


-Somu

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dotnetrajanikanth on: 12/16/2012 [Member] Starter | Points: 25

Up
0
Down
Can you explain what exception you are getting?

Any way its better to do like this

 if (TextBox2.Text == TextBox3.Text && DropDownList1.SelectedItem.Text != null )


{

db.myconnection();

SqlCommand cmd = new SqlCommand("update login set password='" + TextBox2.Text + "', where username='" + DropDownList1.SelectedItem.Text+ "'", db.sqlcon);

cmd.ExecuteNonQuery();

Label2.Text = "Password Updated Successfully";



}

}


____________
www.flickr.com/photos/psdesigner/

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/17/2012 [Member] Starter | Points: 25

Up
0
Down
somu its not working....

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/17/2012 [Member] Starter | Points: 25

Up
0
Down
rajinikanth sir.....actually m getting no error but value not getting inserted in database

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 12/17/2012 [Member] Starter | Points: 25

Up
0
Down
even i hav entered same value in textboxes 2 nd 3

Ankitsrist, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response