我的代码有问题。我想制作一个没有重复帐户的登录系统 C#。谁能帮我这样做?帮助将不胜感激!
private void enterButton_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand da = new SqlCommand("SELECT * FROM RegTable", con);
SqlDataReader reader = null;
reader = da.ExecuteReader();
while (reader.Read())
{
if (usernameTextBox.Text == (reader["Username"].ToString()) && PasswordtextBox.Text == (reader["Password"].ToString()))
{
MessageBox.Show("Welcome!");
canForm x = new canForm();
x.ShowDialog();
this.Hide();
con.Close();
}
else
{
MessageBox.Show("Account Doesn't Exist");
}
}
}