Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void buttonSave_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection("Data Source=DESKTOP-R6KE2IE\SQLEXPRESS;Initial Catalog=passmaker;Integrated Security=True");
- SqlDataAdapter ASDF = new SqlDataAdapter("SELECT COUNT(*) FROM tbl_Login WHERE Password='" + textBoxPassword.Text + "'AND Email ='" + textBoxEmail.Text + "'", con);
- DataTable DS = new DataTable();
- ASDF.Fill(DS);
- ErrorProvider errorProvider = new ErrorProvider();
- errorProvider.Clear();
- if (DS.Rows[0][0].ToString() == "1")
- {
- if (textBoxNew.Text == textBoxOld.Text)
- {
- SqlCommand cmd = new SqlCommand("SELECT * FROM tbl_Login WHERE Password = '" + int.Parse(textBoxPassword.Text) + "'", con);
- con.Open();
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- con.Open();
- SqlCommand smd = new SqlCommand("Insert into tbl_Login(AsusPassword) Values ='" + textBoxNew.Text + "'", con); //SqlCommand smd = new SqlCommand("Insert into tbl_Login(Facebook) Values('" + textBoxNew.Text + "')", con);
- smd.ExecuteNonQuery();
- int i = smd.ExecuteNonQuery();
- con.Close();
- if (i > 0)
- {
- MessageBox.Show("You set your password successfully!!");
- }
- else
- {
- MessageBox.Show("something went wrong");
- }
- con.Close();
- }
- else
- {
- MessageBox.Show("OO my ");
- con.Close();
- }
- }
- else
- {
- MessageBox.Show("Are You Suere You Want To Change Your Password");
- SqlDataAdapter cc = new SqlDataAdapter("update tbl_Login set Facebook = '" + textBoxNew.Text + "' where Password = '" + textBoxPassword.Text + "' and Email ='" + textBoxEmail.Text + "'", con);
- MessageBox.Show("Password changed!!!");
- }
- }
- else
- {
- errorProvider.SetError(textBoxPassword, "Incorrect Password!");
- errorProvider.SetError(textBoxEmail, "Incorrect Email");
- }
- }
Add Comment
Please, Sign In to add comment