使用下面的代码,我想对其进行修改,以便 dataGridView (dgReceived) 被“dateTimePicker1”过滤(如图所示)。从ACCESS数据库中检索数据非常有用,但我需要添加该过滤器功能。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace dataGridView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;data source=C:\Query Form\Database.accdb");
vcon.Open();
DataSet ds = new DataSet();
OleDbDataAdapter daReceived = new OleDbDataAdapter();
OleDbCommand slctReceived = new OleDbCommand("SELECT * FROM script_Received", vcon);
daReceived.SelectCommand = slctReceived;
daReceived.Fill(ds, "tblReceived");
dgReceived.DataSource = ds.Tables["tblReceived"];
}
private void dgReceived_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}