在2个日期之间搜索rcords [英] searching rcords between 2 dates

查看:63
本文介绍了在2个日期之间搜索rcords的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请建议我如何使用日期时间选择器进行操作

please suggest me how to operate with datetime picker

con = new OleDbConnection(provider=microsoft.jet.oledb.4.0;data source=d:/jwlrydb.mdb);
con.Open();
//MessageBox.Show(connected);
da = new OleDbDataAdapter(select * from item where dateTimepicker1 and dateTimepicker2, con);
DataSet ds = new DataSet();
da.Fill(ds,item);
int x = ds.Tables[item].Rows.Count;
if (x == 1)
{
    dataGridView1.DataSource = ds.Tables[item];
}
else
{
    MessageBox.Show(no record found between these dates);
}

推荐答案

您的查询条件应位于"item"表的某些DateTime Type列上.

例如-
Your query condition should be on some DateTime Type column of "item" table.

For Example -
<br />
select * from item where item.COLUMNNAME Between dateTimepicker1.Value and dateTimepicker2.Value<br />


我想您需要使用 ^ ].在尝试实现控件之前,始终值得检查它们的文档.
I guess you need to use this property[^]. It is always worth checking the documentation for your controls before trying to implement them.


请尝试以下操作:

Try this:

string query = string.Format("SELECT * FROM table WHERE col1 BEWTEEN {0} AND {1}", 
                             date1.ToString("mm/DD/yyyy"), 
                             date2.ToString("mm/DD/yyyy"));
da = new OleDbDataAdapter(query, con);


这篇关于在2个日期之间搜索rcords的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆