This is my code with not decentralization users
try
{
if (txtUserName.Text == "" || txtPassword.Text == "")
{
MessageBox.Show("Entry Username and Password", "Error");
txtUserName.Focus();
return;
}
else
{
SqlConnection conn = new SqlConnection(@"Data Source=; Initial Catalog=; uid = sa; pwd = 123456;");
conn.Open();
SqlCommand cmd = new SqlCommand("Select Pass From Account Where UserName ='" + txtUserName.Text + "'", conn);
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
if (txtPassword.Text == reader.GetValue(0).ToString())
{
MessageBox.Show("Login success!", "Success");
reader.Close();
conn.Close();
this.Hide();
Form2 frm2 = new Form2();
frm2.ShowDialog();
}
else
{
MessageBox.Show("Wrong password", "Error");
txtPassword.Focus();
}
reader.Close();
conn.Close();
}
}
catch (Exception)
{
MessageBox.Show("Wrong Username or Password", "Error");
txtUserName.Focus();
}