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

初学C#跪求如何通过选择的日期查询数据库
本帖最后由 u010368731 于 2013-04-21 12:28:16 编辑
初学C#还不怎么会写,想写一个查询用的WEB应该用程序。用了两个TextBox扩展CalendarExtender控件来选择查询区间查询数据库,以生成GridView的数据源。跪求中间的代码要怎么写。

------解决方案--------------------
select * from xxx where datefield between @date1 and @date2
自己给date1和date2赋值就行了
------解决方案--------------------
sql = "select * from table where date between " + dtp1.Value.ToString() + " and " + dtp2.Value.ToString();
------解决方案--------------------
Refer:

http://www.cnblogs.com/insus/archive/2013/04/06/3002054.html
------解决方案--------------------
this.tbx_Date.Text = this.cld_Date.SelectedDate.ToString("yyyy-MM-dd");


cld_Date是日历控件的名字,
tbx_Date是TextBox控件的名字。。。