我使用下面的代码过滤数据从一个日期到另一个日期不起作用 [英] i use the below code to filter data from one date to another its not working

查看:44
本文介绍了我使用下面的代码过滤数据从一个日期到另一个日期不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void button5_Click(object sender,EventArgs e)

{

bs.DataSource = dataGridView2.DataSource;

bs.Filter = string.Format(" select * from sales_details,其中日期介于'" + dateTimePicker2.Text +"'和'" + dateTimePicker3.Text +"'");

dataGridView2。 DataSource = dt;

}

解决方案

请参阅文档:

直接在数据表中过滤和排序 [ ^ ]

< a href =http://msdn.microsoft.com/en-us/library/det4aw50%28v=vs.110%29.aspx> DataTable.Select方法(字符串) [ ^

private void button5_Click(object sender, EventArgs e)
{
bs.DataSource = dataGridView2.DataSource;
bs.Filter = string.Format("select * from sales_details where date between '"+dateTimePicker2.Text+"' and '" +dateTimePicker3.Text+"'");
dataGridView2.DataSource = dt;
}

解决方案

Please, see the documentation:
Filtering and Sorting Directly in Data Tables[^]
DataTable.Select Method (String)[^]


这篇关于我使用下面的代码过滤数据从一个日期到另一个日期不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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