dataset的查询问题
我使用ACCESS建的数据库,想实现时间的查询
在ACCESS中查询正常.
SELECT set_rule.rule_name, set_rule.time_start, set_rule.time_end
FROM set_rule where Format(#2007-02-09 00:06:00#, 'hh:mm:ss ') > = Format(time_start, 'hh:mm:ss ') and Format(#2007-02-09 00:06:00#, 'hh:mm:ss ') <= Format(time_end, 'hh:mm:ss ');
但在DataSet中不知道怎么实现.
我用下面这种方法出现错误.提示 "未定义的函数定义:Format() "
string str_sql = "Format(# " + _dt.ToString() + "#, 'hh:mm:ss ') > = Format(time_start, 'hh:mm:ss ') and Format(# " + _dt.ToString() + "#, 'hh:mm:ss ') <= Format(time_end, 'hh:mm:ss ') ";
DataRow[] dr_state = fm.databaseDataSet1.set_rule.Select(str_sql);
请问.怎么可以在DataTable是怎么使用Select数据来实现时间查询?
谢谢~
------解决方案--------------------str_sql = " Convert( ' " + _dt.ToString() + " ', 'System.DateTime ') > =convert(time_start, 'System.DateTime ') and Convert( ' " + _dt.ToString() + " ', 'System.DateTime ') <= Convert( time_end, 'System.DateTime ') "
------解决方案--------------------可以参考如下
string sTime = "2007-1-8 ";
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "dDate <= ' " + sTime+ " ' ";//无需类型转换,但是要保证sTime的值有意义,例如可以考虑sTime的值是由datetimepicker控件得来
this.dataGridView1.DataSource = dv;
------解决方案--------------------string str_sql = "time_start > = " + Convert.ToDateTime( "2007-6-14 ");
DataRow[] dr_state = fm.databaseDataSet1.set_rule.Select(str_sql);