Private Sub radbtnImport_Click(sender As Object, e As EventArgs) Handles radbtnImport.Click Dim objConnection As New SqlConnection objConnection = New SqlConnection(My.Settings.CS) objConnection.Open() Dim MyConnection As System.Data.OleDb.OleDbConnection Dim DtSet As System.Data.DataSet Dim MyCommand As System.Data.OleDb.OleDbDataAdapter Dim fBrowse As New OpenFileDialog With fBrowse .Filter = "Excel files(*.xlsx)|*.xlsx|All files (*.*)|*.*" .FilterIndex = 1 .Title = "Import data from Excel file" End With If fBrowse.ShowDialog() = Windows.Forms.DialogResult.OK Then Dim fname As String fname = fBrowse.FileName MyConnection = New System.Data.OleDb.OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0; Data Source='" & fname & " '; " & "Extended Properties=Excel 8.0;") MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Personal]", MyConnection) MyCommand.TableMappings.Add("Table", "Test") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet)'-- here i get error "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine." MyConnection.Close() For Each Drr As DataRow In DtSet.Tables(0).Rows ''Here just i try to retive the data form excel one by one Dim Name As String = Drr(0).ToString Dim LastName As String = Drr(1).ToString Dim Contact As String = Drr(2).ToString Dim Phone As String = Drr(3).ToString Next End If End Sub
MyConnection = New System.Data.OleDb.OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0; Data Source='" & fname & " '; " & "Extended Properties=Excel 8.0;")
MyConnection = New System.Data.OleDb.OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source='" & fname & " '; " & "Extended Properties=Excel 12.0;")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)