Azm Amn

Azm Amn

  • NA
  • 108
  • 18k

Change password in Asp.Net

Mar 25 2017 8:23 AM
Hi,
 
I have many users in my system and i want all users to change their passwords respectively.
 
My code:
protected void Button1_Click(object sender, EventArgs e)
{
try
{
if (Label2.Text.Contains("@iumw.edu.my"))
{
if (TextBox1.Text == SqlDataSource1.SelectCommand)
{
if (TextBox2.Text == TextBox3.Text)
{
Label3.Visible = true;
Label3.Text = "";
con.Open();
SqlCommand cmd = new SqlCommand("Update [Programme Leader] set Password='" + TextBox3.Text + "'where Username='" + Session["username"].ToString() + "'", con);
cmd.ExecuteNonQuery();
con.Close();
Label3.ForeColor = System.Drawing.Color.Red;
Label3.Text = "Password Changed Successfully";
}
}
}
if (Label2.Text != "")
{
if (TextBox1.Text == SqlDataSource2.SelectCommand)
{
if (TextBox2.Text == TextBox3.Text)
{
Label3.Visible = true;
Label3.Text = "";
con.Open();
SqlCommand cmd = new SqlCommand("Update Student set Password='" + TextBox3.Text + "'where Username='" + Session["username"].ToString() + "'", con);
cmd.ExecuteNonQuery();
con.Close();
Label3.ForeColor = System.Drawing.Color.Red;
Label3.Text = "Password Changed Successfully";
}
}
}
if(TextBox2.Text != TextBox3.Text)
{
Label3.Visible=true;
Label3.Text = "";
Label3.ForeColor = System.Drawing.Color.Red;
Label3.Text = "The Passwords Do Not Match";
}
}
catch
{
}
}
}
}
 
I think i need a stored procedure to do this, but i dont know how to do it. please help me
 
Thanks 
 

Answers (1)