Reputation: 35
i was having a problem about this . it could not find installbe ISAM i've already change the target cpu in x86 Image of error
Dim con_excel As New System.Data.OleDb.OleDbConnection(" Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & TextBox1.Text & "'; Extend Poroperties="" Excel 16.0;HDR=No"" ")
con_excel.Open()
Dim qry_excel As String = "Select * from [Sheet1$]"
and i already install a AccessDatabaseEngine for this
and im using excel 2016 should i use this
Extend Poroperties="" Excel 16.0;HDR=Yes""
or
Extend Poroperties="" Excel 12.0;HDR=Yes""
Upvotes: 0
Views: 2128
Reputation: 32248
You have a nasty syntax error in your connection string:
"'; Extend Poroperties="" Excel 16.0;HDR=No"" ")
Extend => Extended
Poroperties => Properties
This should be (set HDR
to whatever is needed. Leave IMEX=1
for safety):
";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1;"""
Change it in:
Dim ConnectionString As String =
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & TextBox1.Text &
";Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""
Or:
Dim ConnectionString As String =
"Provider=Microsoft.ACE.OLEDB.16.0;Data Source=" & TextBox1.Text &
";Extended Properties=""Excel 16.0 Xml;HDR=YES;IMEX=1"""
Dim con_excel As New OleDbConnection(ConnectionString)
Note that TextBox1.Text
must provide the full path to the Excel file.
Download and install the required Database engines (32bit or 64bit).
Microsoft Access Database Engine 2010 Redistributable
Microsoft Access Database Engine 2016 Redistributable
About the Compile
mode:
Set Project properties => Compile => AnyCPU
Set VS Debug Mode => AnyCPU
Upvotes: 1