我用vs2010做了一个简单的数据库管理系统,设计了一个登陆界面,在里面放置了一个combobox,标签是“身份”,设置的Item为“学生“和”老师”,运行的时候,我想先选择身份,在判断输入的编号和密码是否正确,在跳转窗体,代码如下: private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection cn = new SqlConnection();
                cn.ConnectionString = "Data Source=HUAN-PC;Initial Catalog=stdent;Integrated Security=True";
                if (comboBox1.Text == "学生")
                {
                    
                    String mysqlTwo = "select StudentID,Password from Student where Password='" + textBox1.Text + "'and StudentID='" + textBox2.Text + "'";
                    SqlCommand cmd2 = new SqlCommand(mysqlTwo, cn);
                    cn.Open();
                    SqlDataReader dr2 = cmd2.ExecuteReader();
                   if (dr2.Read())
                    {
                        MessageBox.Show("登录成功!");
                        Form选择界面 f1 = new Form选择界面();
                        f1.Show();
                        dr2.Close();
                        
                    }
                    else
                    {
                        MessageBox.Show("你输入的用户名或密码不正确");
                    }
                }                else if (comboBox1.Text == "教师")
                    
                {
                   
                    String mysqlOne = "select TeacherID,Password from Teacher where Password='"+textBox1.Text+"'and TeacherID='" + textBox2.Text + "'";
                    SqlCommand cmd1 = new SqlCommand(mysqlOne, cn);
                    cn.Open();
                    SqlDataReader dr1 = cmd1.ExecuteReader();
                    if (dr1.Read())
                    {
                        MessageBox.Show("登录成功!");
                        Form选择界面 f2 = new Form选择界面();
                        f2.Show();
                        dr1.Close();
                    }
                    else
                    {
                        MessageBox.Show("你输入的用户名或密码不正确");
                    }
                }                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
但是运行的时候有个问题,当选择”教师“身份时,编号和密码为空时也能登陆成功,请高手指点,怎样在编号和密码为空时,弹出密码错误提示,不是登陆,学生已经实现了这个功能