0
私はC#でログインフォームを持っていますが、管理者はユーザー名として「admin」、パスワードとして「admin」でログインします。 2回目以降のログインでデフォルトの管理者の資格情報を受け入れないように変更したいと思います。管理者が最初にログインした後のC#登録フォーム
private void btnlogin_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("Data Source=(local);Initial Catalog=login1;Integrated Security=True");
cn.Open();
SqlCommand cmd = new SqlCommand("select * from user2 where username = '"+textBox1.Text+"' and password = '"+textBox2.Text+"'", cn);
SqlDataReader dr;
dr = cmd.ExecuteReader();
int count = 0;
while (dr.Read())
{
count += 1;
}
if (count == 1)
{
MessageBox.Show("OK");
Form2 frm2 = new Form2();
frm2.Show();
}
else if (count > 0)
{
MessageBox.Show("Duplicate usernameand password");
}
else
{
MessageBox.Show("username and password is incorrect", "Please try again");
}
textBox1.Clear();
textBox2.Clear();
}
private void btnexit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
どのように私は私が説明した改訂動作を実装することができます:ここで
は私の現在のコードですか?
あなたが書いたコードを投稿してください。 – n1c9