private void button1_Click(object sender, EventArgs e)
{
DialogResult i = MessageBox.Show("是否确定", "确定", MessageBoxButtons.YesNo);
toolStripStatusLabel1.Text = "确认";
SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Data Source=***;Initial Catalog=****;Integrated Security=true";
connection.Open();
SqlCommand cmd = new SqlCommand("select *from Consumer where Name='" + textBox1.Text + "'and Password='" + textBox2.Text + "'", connection);
SqlDataReader myReader = cmd.ExecuteReader();
if (i == DialogResult.Yes && myReader.Read())
{
if (label4.Text == textBox3.Text)
{
this.Visible = false;
Form2 go = new Form2();
go.Visible = true;
}
if (label4.Text != textBox3.Text && textBox3.Text != "")
{
MessageBox.Show("验证码输入错误", "出错了", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (textBox3.Text == "")
{
MessageBox.Show("请输入验证码", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
else
{
MessageBox.Show("请输入正确的内容");
}
if (i == DialogResult.No)
{
return;
}
connection.Close();
}
我现在把代玛改成用SQL语句直接进行判断 但这样的话我如果用户名输入正确了 密码错了 我想显示一句“密码错误”也不行 不知道怎么弄 只能同时判断用户名和密码和表中的是否一样 不能判断是用户名输入错误还是密码输入错误!