Hi Everyone,
I am pulling different information from the same file at two different times:
1) The first time, I pull information that is inserted into a combobox. I need to use the combobox as a filter for when I pull the information a second time. 2) I pull different information from the same file, and it is outputted into a datagridview table. I already have a filter in place when the information is pulled the second time, and I was wondering if I could add to that filter or if I have to make another filter?
The filter (or filters) will be used to filter the information in the datagridview before it is outputted in a chart. Let me know if any of this was confusing!
This is the code for binding the combobox to the information
Here is the code for the 2nd information pull where I need the filter?Code:Dim cnRange As String = "provider=Microsoft.Jet.OLEDB.4.0; " & _ "data source='" & strFileName & "';" & _ "Extended Properties=""Excel 8.0; IMEX=1; HDR=No;""" 'moApp.Visible = True Using MyConnection As New System.Data.OleDb.OleDbConnection(cnRange) MyConnection.Open() Dim da As New OleDbDataAdapter( _ "SELECT DISTINCT * FROM [Sheet1$O5:O]", MyConnection) Dim dt As New DataTable da.Fill(dt) dateComboBox.DisplayMember = dt.Columns(0).ColumnName dateComboBox.DataSource = dt ediDate = dateComboBox.SelectedItem.ToString() End Using
Thanks for your help!Code:Private Sub dataButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dataButton.Click Dim cnRange As String = "provider=Microsoft.Jet.OLEDB.4.0; " & _ "data source='" & strFileName & "';" & _ "Extended Properties=""Excel 8.0; IMEX=1; HDR=No;""" 'moApp.Visible = True Using MyConnection As New System.Data.OleDb.OleDbConnection(cnRange) MyConnection.Open() Dim cmd As OleDbCommand = New OleDbCommand( _ "SELECT * FROM [Sheet1$J4:O]", MyConnection) Dim dr As System.Data.IDataReader = cmd.ExecuteReader Dim dt As New DataTable dt.Load(dr) DataGridView1.DataSource = dt Me.BindingSource1.DataSource = dt Me.BindingSource1.Filter = String.Format("F1 = '76812SNE A010M2'".ToString) Chart1.DataSource = BindingSource1 Chart1.Series("Series1").XValueMember = "F3" Chart1.Series("Series1").YValueMembers = "F4" Chart1.DataBind() End Using End Sub




Reply With Quote
