关于查询刷新问题高手请进
s_ds1.Clear();
s_adapter.SelectCommand.CommandText= "SELECT kpid AS 编号, kpxm AS 姓名, kpxb AS 性别, kpdh AS 电话, kplb AS 类别, kpkc AS 课程, kpsj AS 时间段 FROM students WHERE kpid=? ";
s_adapter.SelectCommand.Parameters.Add( "@kpid ",s_bh.Text);
s_adapter.Fill(s_ds1);
这段代码我是放在一个按扭上.目的是在S_BH.TEXT 里面输入查询条件.然后把结果显示在DATAGRID
第一次输入可以得到结果,可是第二次就没有反映了.请高手指点下.
------解决方案--------------------s_ds1.Clear();
s_adapter.SelectCommand.CommandText= "SELECT kpid AS 编号, kpxm AS 姓名, kpxb AS 性别, kpdh AS 电话, kplb AS 类别, kpkc AS 课程, kpsj AS 时间段 FROM students WHERE kpid=? ";
s_adapter.SelectCommand.Parameters.Add( "@kpid ",s_bh.Text);
s_adapter.Fill(s_ds1);
this.dataGrid1.DataSource = s_ds1.Tables[0];
------解决方案--------------------s_ds1.Clear();
s_adapter.SelectCommand.CommandText= "SELECT kpid AS 编号, kpxm AS 姓名, kpxb AS 性别, kpdh AS 电话, kplb AS 类别, kpkc AS 课程, kpsj AS 时间段 FROM students WHERE kpid=? ";
s_adapter.SelectCommand.Parameters.Add( "@kpid ",s_bh.Text);
s_adapter.Fill(s_ds1);
============================================================
DataSet s_ds1 = new DataSet(); // 每次都实例化一个
s_adapter.SelectCommand.CommandText= "SELECT kpid AS 编号, kpxm AS 姓名, kpxb AS 性别, kpdh AS 电话, kplb AS 类别, kpkc AS 课程, kpsj AS 时间段 FROM students WHERE kpid=? ";
s_adapter.SelectCommand.Parameters.Add( "@kpid ",s_bh.Text);
s_adapter.Fill(s_ds1);
------解决方案--------------------DataSet s_ds1 = new DataSet(); // 每次都实例化一个
s_adapter.SelectCommand.CommandText= "SELECT kpid AS 编号, kpxm AS 姓名, kpxb AS 性别, kpdh AS 电话, kplb AS 类别, kpkc AS 课程, kpsj AS 时间段 FROM students WHERE kpid=? ";
s_adapter.SelectCommand.Parameters.Add( "@kpid ",s_bh.Text);
s_adapter.Fill(s_ds1);
这么干估计问题也就解决了。。。但是。。。。。。。。。。。。
程序员要学会调试啊!!!!!!!