C# datetimepicker查询数据库
用2个datetimepicker实现查询时间段数据,如下stringa,b;a=this.dateTimePicker1.Value.ToShortDateString...
用2个datetimepicker实现查询时间段数据,如下
string a,b;
a=this.dateTimePicker1.Value.ToShortDateString();
b=this.dateTimePicker2.Value.ToShortDateString();
string str="select * from Furn_Info where Time between ‘"+from+"’
and ‘"+to+"’";
写出来不行,我现在不知道where 后面该怎么写了?我用的是SQL2000,Time的属性是Datetime的,请高手指教! 展开
string a,b;
a=this.dateTimePicker1.Value.ToShortDateString();
b=this.dateTimePicker2.Value.ToShortDateString();
string str="select * from Furn_Info where Time between ‘"+from+"’
and ‘"+to+"’";
写出来不行,我现在不知道where 后面该怎么写了?我用的是SQL2000,Time的属性是Datetime的,请高手指教! 展开
1个回答
展开全部
str="select * from Furn_Info where Time between '"
+ this.dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm:ss")
+ "' and '" +
this.dateTimePicker2.Value.ToString("yyyy-MM-dd hh:mm:ss")
+ "'"
+ this.dateTimePicker1.Value.ToString("yyyy-MM-dd hh:mm:ss")
+ "' and '" +
this.dateTimePicker2.Value.ToString("yyyy-MM-dd hh:mm:ss")
+ "'"
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询