1
使用我的代码如下,我想修改它,以便dataGridView(dgReceived)由“dateTimePicker1”(如图所示)过滤。它很适合从ACCESS数据库中检索数据,但我需要添加该过滤器功能。通过datetimepicker值筛选访问填充dataGridView C#
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)
{
}
}
}
哪里,在代码中,我插入绑定?我想确保在正确的地方插入 “公共课”。 – Geo 2012-04-26 17:50:35
我给了你一个链接到文档,RTFM;) – Tergiver 2012-04-26 17:53:59