Hi Everyone,
I have bound data from Excel to my project, but now I am trying to pull a specific column from the table and put the information in a combobox. I am trying to pull dates from column O of my excel file, and I want the dates to go into the combobox with no repeats. Does anyone have any suggestions?
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 cmd As OleDbCommand = New OleDbCommand( _ "SELECT * FROM [Sheet1$O]", MyConnection) 'Throws an error that [Sheet1$O] is not valid Dim dr As System.Data.IDataReader = cmd.ExecuteReader Dim dt As New DataTable While dr.Read() dateComboBox.Items.Add(dr.Item("*").ToString) End While End Using




Reply With Quote
