日期:2014-05-17  浏览次数:20594 次

哪位大神能帮我看下代码哪里错了吗?
private void button3_Click(object sender, EventArgs e)
        {
            serach();
        }
        public void serach()
        {
            // sqlInit();
            // Database conn = new Database();
            connection = new OleDbConnection(ConnStr);
            connection.Open();
            string s = textBoxSelectName.Text;
            string selectStudentInfo = "SELECT  * FROM [Student]  WHERE [姓名]='"+ textBoxSelectName +"'";
            OleDbDataAdapter Adap = new OleDbDataAdapter(selectStudentInfo, connection);
            DataSet data = new DataSet();
            Adap.Fill(data,"Student");                         
            DataSet ds = data;
            dataGridViewSelectStudentManage.DataSource = ds.Tables["Student"];
            connection.Close();

        }
数据库的链接,添加都实现了,就是这个查询实现不了,输入名字的话,不出来结果,只出来一行空白。听说CSDN上的大神很多,特来求教!

------解决方案--------------------
-_-

string selectStudentInfo = "SELECT  * FROM [Student]  WHERE [姓名]='"+ textBoxSelectName +"'";

textBoxSelectName明显是textbox对象啊,好心调试一下啊
------解决方案--------------------
目测没有问题,你拿断点跟一下,把sql语句在数据库中运行一下看有没有结果。
------解决方案--------------------
string selectStudentInfo = "SELECT  * FROM [Student]  WHERE [姓名]='"+ s +"'";