您需要按日期进行过滤,表格通过以下代码填充:
DataSet dataSet = new DataSet();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
OleDbDataAdapter dataAdapter1 = new OleDbDataAdapter();
string query = "select * from Договор";
string query1 = "select * from Поставщики";
conn = new OleDbConnection(conn_string);
dataAdapter.SelectCommand = new OleDbCommand(query, conn);
dataAdapter1.SelectCommand = new OleDbCommand(query1, conn);
dataAdapter.TableMappings.Add("Table", "Договор");
dataAdapter1.TableMappings.Add("Table", "Поставщики");
dataAdapter.Fill(dataSet);
dataAdapter1.Fill(dataSet);
BindingSource dogSource = new BindingSource();
dogSource.DataSource = dataSet;
dogSource.DataMember = "Договор";
dataGridView1.DataSource = dogSource;
BindingSource postSource = new BindingSource();
postSource.DataSource = dataSet;
postSource.DataMember = "Поставщики";
DataGridViewComboBoxColumn comboColumn = new DataGridViewComboBoxColumn();
comboColumn.HeaderText = "Поставщики";
comboColumn.DataSource = postSource;
comboColumn.DataPropertyName = "Код поставщика";
comboColumn.DisplayMember = "Название";
comboColumn.ValueMember = "Код поставщика";
以前,我在任何地方都使用过过滤,
DataView dv = new DataView(dt);
dv.RowFilter = string.Format(" CONVERT([Дата заключения], 'System.DateTime') >= '{0:dd.MM.yyyy}' AND CONVERT([Дата заключения], 'System.DateTime') <= '{0:dd.MM.yyyy}'",
dateTimePicker1.Value.ToShortDateString());;
dataGridView1.DataSource=dv;
但现在这不起作用,很可能是因为 DataSource。不幸的是,我不是这方面的专家,我将不胜感激。
我不确定代码在语言方面是否正确,但它可以正常工作。