SqlDataAdapter会自动找开数据连接,应与Open没关于.
TO:楼主.
单步运行一下,看问题出在哪一个语句上,再看看你的SQL语句,在sql的查询分析器上运行一下看看结果是不是你想要的,还有就是在读取TextBox中的文本时,最好还是加上Trim方法. 即:
string strUserID = textBox1.Text.Trim();
string strUserPwd = textBox2.Text.Trim();

        private void button1_Click(object sender, EventArgs e)
        {
            
            string b = this.textBox1.Text.ToString();
            string a = this.comboBox2.SelectedItem.ToString();
            if (b == "")
            {
                MessageBox.Show("密码为空,请确认!!");
            } 
            conn.Open();
            SqlCommand comm3 = new SqlCommand("select * from jkgeng where name='"+a+"' and pwd='"+b+"'" ,conn);
            SqlDataReader reader = comm3.ExecuteReader();
            if (reader.Read())
            {
                
                Form1 f1 = new Form1();
                f1.ShowDialog();
                this.Close();
                
            }
            else
            {
                MessageBox.Show("密码错误,请重新输入!!");
                this.textBox1.Text = "";
                
            }
        }
我的登录代码!!