can someone help me take a look i face (oledbexception was unhandled (too many fields defined))
below is my code .

Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click

 Properties='Excel 12.0;HDR=NO;'"
 Dim Chosen_File As String = ""

    If openFileDialog1.ShowDialog() = DialogResult.OK Then
        Chosen_File = openFileDialog1.FileName
    End If

    If Chosen_File = String.Empty Then
        Return
    End If

    InputExcel.Text = Chosen_File

    Dim ds = New DataSet()
    Dim path = InputExcel.Text
    Dim con As String = "provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1;';"

    If InputExcel.Text = ".xlsx" Then
        MessageBox.Show("Wrong File Type", "Error Message")
        Return
    End If

    Using connection As OleDbConnection = New OleDbConnection(con)
        connection.Open()
        Dim sheets As DataTable = GetSchemaTable(con)
        For Each r As DataRow In sheets.Rows
            Dim data As DataTable = New DataTable()
            ComboBox1.Items.Add(r("TABLE_NAME").ToString())
            Dim query As String = "SELECT * FROM [" & r("TABLE_NAME").ToString() & "]"
            Dim adapter = New OleDbDataAdapter(query, connection)
            adapter.Fill(data)
            ds.Tables.Add(data) 'Table1
        Next
    End Using
End Sub
Private Function GetSchemaTable(ByVal connectionString As String) As DataTable
    Using connection As OleDbConnection = New OleDbConnection(connectionString)
        connection.Open()
        Dim schemaTable As DataTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"})
        Return schemaTable
    End Using
End Function

Capture.PNG

How many columns are defined in your table?

commented: thanks for you replay. My excel file current have around 1000 column +0

1000? Do you need all of them? Apart from the adapter not loading them, this will become a huge performance hit.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.