Cannot access Excel sheet data from Visual Basic.Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Developers,

I am trying to access an Excel data file through a VB.Net application.
I have the following code:

=================================== VB.Net Code ===================
Dim sSqlString = ""
Dim rCount As Integer = 0
Dim sDataSet As New DataSet()
sSqlString = "Select * From [Sheet1$]"
Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "E:\Visual Basic.NET\DataOne" + ";Extended Properties=Excel 8.0;HDR=YES;"
Dim dbConn As New OleDbConnection(sConnString)
Dim sCommandSelect As New OleDbCommand(sSqlString, dbConn)

Try
sCommandSelect.Connection.Open()
Catch ex As OleDbException
MessageBox.Show(ex.Message, ex.ErrorCode)
End Try
=========================================================

Each time I hit the statement "sCommandSelect.Connection.Open()" above, I got the following error:

"Could not find installable ISAM"

Excel 2002 and Visual Studio.Net are both fully and successfully installed.
Anyone knows why it would not make work?

Sincerely,
Omar
P.S. Please cc your reply to my email: (e-mail address removed)
 
Hi,

You get that error if when ado.net is unable to open the data
source. Shouldn't your data source be something like this "E:\Visual
Basic.NET\DataOne.xls" + "; not "E:\Visual Basic.NET\DataOne" + ";

Ken
-------------------------------

Omar said:
Hi Developers,

I am trying to access an Excel data file through a VB.Net application.
I have the following code:

=================================== VB.Net Code ===================
Dim sSqlString = ""
Dim rCount As Integer = 0
Dim sDataSet As New DataSet()
sSqlString = "Select * From [Sheet1$]"
Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + "E:\Visual Basic.NET\DataOne" + ";Extended Properties=Excel
8.0;HDR=YES;"
 
i don't know
-----Original Message-----
Hi,

You get that error if when ado.net is unable to open the data
source. Shouldn't your data source be something like this "E:\Visual
Basic.NET\DataOne.xls" + "; not "E:\Visual Basic.NET\DataOne" + ";

Ken
-------------------------------

Hi Developers,

I am trying to access an Excel data file through a VB.Net application.
I have the following code:

=================================== VB.Net Code ===================
Dim sSqlString = ""
Dim rCount As Integer = 0
Dim sDataSet As New DataSet()
sSqlString = "Select * From [Sheet1$]"
Dim sConnString As String
= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" + "E:\Visual Basic.NET\DataOne" + ";Extended Properties=Excel ============================================
=============
statement "sCommandSelect.Connection.Open()" above, I
 
¤ Hi Developers,
¤
¤ I am trying to access an Excel data file through a VB.Net application.
¤ I have the following code:
¤
¤ =================================== VB.Net Code ===================
¤ Dim sSqlString = ""
¤ Dim rCount As Integer = 0
¤ Dim sDataSet As New DataSet()
¤ sSqlString = "Select * From [Sheet1$]"
¤ Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "E:\Visual Basic.NET\DataOne" + ";Extended Properties=Excel 8.0;HDR=YES;"
¤ Dim dbConn As New OleDbConnection(sConnString)
¤ Dim sCommandSelect As New OleDbCommand(sSqlString, dbConn)
¤
¤ Try
¤ sCommandSelect.Connection.Open()
¤ Catch ex As OleDbException
¤ MessageBox.Show(ex.Message, ex.ErrorCode)
¤ End Try
¤ =========================================================
¤
¤ Each time I hit the statement "sCommandSelect.Connection.Open()" above, I got the following error:
¤
¤ "Could not find installable ISAM"
¤
¤ Excel 2002 and Visual Studio.Net are both fully and successfully installed.
¤ Anyone knows why it would not make work?

Your connection string syntax is bad. It gets a little tricky when you have additional Extented
Properties and you also need to specify the Excel filename:

"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\Visual Basic.NET\DataOne\ExcelFileName.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes"""


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top