日期:2014-05-19  浏览次数:20686 次

select between 语句问题出在哪?
我想查询一个时间段间的数据,时间的选择通过dataTimePicker控件选择。数据库表格中   “日期”的类型是字符串。
程序中语句如下:
string   a=this.dateTimePicker1.Value.ToString();
string   b=this.dateTimePicker2.Value.ToString();
string   sendTableName= "采购单历史 ";
string   sendStrSQL= "select*from   采购单历史   where   采购日期   between   a   and   b "
this.ds=link.SelectDataBase(sendStrSQL,sendTableName);
this.dataGrid1.DataSource=ds.Tables[0];
运行的问题就出在SQL语句上,主要就是变量a   和   b   请高手指教一下问题出在哪?

------解决方案--------------------
string sendStrSQL= "select*from 采购单历史 where 采购日期 between ' "+a+ " ' and ' "+b+ " ' ";