I'm Having issues updating password for users in my assignment. As it requires to have 3 textbox one for the current password, and the to others are one for new password and one to confirm the new password. I try different methods but it is not updating. the user can log in successfully but i cant update the password. this is my code for login part:
public static string settext = "";
public Admin_Login_Form()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=DESKTOP-CJGIQ74;Initial Catalog=logininfo;Integrated Security=True");
con.Open();
string newcom = "select Name from login where Name='" + textBox1.Text + "' AND password= '" + textBox2.Text + "'";
SqlDataAdapter adp = new SqlDataAdapter(newcom,con);
DataSet ds = new DataSet();
adp.Fill(ds);
DataTable dt = ds.Tables[0];
if (dt.Rows.Count>=1)
{
settext = textBox1.Text;
Admin_Main_Page Main = new Admin_Main_Page();
Main.Show();
this.Hide();
}
else
{
label5.Text = "Invalid Data";
}
}
And this is my registration part:
private void SignUpAdmin_But_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=DESKTOP-CJGIQ74;Initial Catalog=logininfo;Integrated Security=True");
con.Open();
string newcom = "insert into login(Name,password,email,address,contact,creditcard) VALUES ('"+NameTxtb_Admin.Text+"','"+PasswordTxtb_Admin.Text + "','" + EmailTxtb_Admin.Text + "','" + AddressTxtb_Admin.Text + "','" + ContactTxtb_Admin.Text + "','" + CreditCardTxtb_Admin.Text + "')";
SqlCommand cmd = new SqlCommand(newcom , con);
cmd.ExecuteNonQuery();
MessageBox.Show("Congratulations… You've been registered!");
this.Close();
}
Note: i know i didn't use parameters i just noticed, by browsing this site.
Anyone guys have an idea what is the code for this issue?