Saman Udaya

Saman Udaya

  • NA
  • 2
  • 849

All ways show this error "Confirm Password Not Matching With

Jun 12 2018 12:32 AM
private void button1_Click(object sender, EventArgs e)
{
if (txtFirstName.Text == "" || txtUserName.Text == "" || txtPassword.Text == "" || txtConfirPassword.Text == "")
{
MessageBox.Show("Not Allowed Empty Field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(txtPassword.Text) && string.IsNullOrEmpty(txtPassword.Text) && txtPassword.Text.Equals(txtConfirPassword.Text))
{
int i = 0;
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from tblAddUser where UserName='" + txtUserName.Text + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
i = Convert.ToInt32(dt.Rows.Count.ToString());
if (i == 0)
{
SqlCommand cmd1 = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into tblAddUser values('" + txtFirstName.Text + "','" + txtLastName.Text + "','" + txtUserName.Text + "','" + txtPassword.Text + "','" + txtConfirPassword.Text + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("Sucess");
return;
}
else
{
MessageBox.Show("User Name Is Already Exits");
return;
}
}
else
{
MessageBox.Show("Confirm Password Not Matching With Password");
// return;
}

Answers (4)