0

I'm looking for a way to import data from excel 2007 to vb.net 2008 express. I search through the net and found some useful solution like using OLEDB. I have this code below but it is showing error.

Imports System.Data.SqlClient
Public Class readexfile

Private Sub Button1_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myConnection As System.Data.OleDb.OleDbConnection
Dim DSet As System.Data.DataSet
Dim myCommand As System.Data.OleDb.OleDbAdapter

myConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0; Data Sourcer='C:/Documents/Sample.xlsx'; Extended Properties=Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("Select * from [Sheet1$]", myConnection)
MyCommand.TableMappings.Add("Table", "TestTable")
DSet = New System.Data.DataSet
MyCommand.Fill(DSet)
DataGridView1.DataSource = DSet.Tables(0)
myConnection.Close()

End Sub

End Class

The Error Shows:

The 'Microsoft.ACE.OLEDB12.0' provider is not registered on the local machine.

I searched through the web looking for solution to this error,and some website tells me to install Microsoft Access Database Engine. Im currently downloading it, but for now,

I want to ask if is there some other way to import data from excel to datagrid in vb.net?

im using windows 7 64 bit, Microsoft Office 2007, MySQL Database

thanks,

User2341
  • 45
  • 3
  • 14

0 Answers0