提示第一行 “*"附近有错误,如何解决?
private void button1_Click(object sender, EventArgs e)
{
if ((textBox1.Text == "") || (textBox2.Text == ""))
{//对用户名和密码的空值判断
//设置窗体的max和min属性为false
MessageBox.Show("请输入用户名和密码!", "温馨提示!", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else //连接数据库并验证
{
string loginid,loginpwd;
loginid = textBox1.Text.Trim();
loginpwd = textBox2.Text.Trim();
string sql = string.Format("SELECE COUNT(*) FROM admin where name='{0}' and password='{1}'", loginid, loginpwd);
try//打开数据库连接
{
//创建command对象
SqlCommand command=new SqlCommand(sql,Database.connection);
Database.connection.Open();
//MessageBox.Show("OKOK");
int count = (int)command.ExecuteScalar();
if (count < 1)
{
MessageBox.Show("用户名和密码查询不存在!", "温馨提示!", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
else
{
}
}