代码是private void button1_Click(object sender, System.EventArgs e)
{
if(radioButton1.Checked==true)
{
sqlConnection1.Open();

int i=0;
if(textBox1.Text.Trim()=="")
{
MessageBox.Show("用户名不能为空!","注意",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else if(textBox2.Text.Trim()=="")
{
MessageBox.Show("密码不能为空!","注意",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
if(i<2)
{
sqlCommand1.Parameters.Add("@AdminId",System.Data.SqlDbType.VarChar,10);
sqlCommand1.Parameters.Add("@Adminpw",System.Data.SqlDbType.VarChar,10);
sqlCommand1.Parameters["@AdminId"].Value=textBox1.Text;
sqlCommand1.Parameters["@Adminpw"].Value=textBox2.Text;//加密
sqlCommand1.Connection.Open();
    int n=(int)sqlCommand1.ExecuteScalar();
sqlCommand1.Connection.Close();
    sqlCommand1.Dispose();
if(n!=0)
{
//登录成功
Form10 f20= new Form10();
this.Hide();
f20.ShowDialog();
this.Close();
}
else
{
MessageBox.Show("登录失败!请重新输入!","失败",MessageBoxButtons.OK,MessageBoxIcon.Warning);
textBox2.Text="";
textBox2.Focus();
i++;
}
}
else
{
MessageBox.Show("已超过三次!系统退出!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Close();
} }
我已经拖控件并设置sqlCommand1.text=select count(*) from AdminInfo where AdminId=@AdminId and Adminpw=@Adminpw了
请帮帮忙,急啊,我是个菜鸟