Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI all,

Please advice me on how to get rid of the error-
"Cannot find installable ISAM" when I try to connect to an Excel doc from ASP.NET app.

I read up on it and evryone says its because of the connection string and if I use jet.4.0 and Extended Properties is set to Excel 8.0 it should work, but I am still getting the erorr.

The code is:

VB
Protected Function ExcelConnection() As OleDbCommand
    Dim xConnStr As String = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\Users\Arnold\Desktop\Annexcelweb\ExcelImport.xlsx;Extended Properties=Excel 8.0;HDR = YES;IMEX = 1"

    ' create your excel connection object using the connection string
    Dim objXConn As New OleDbConnection(xConnStr)
    objXConn.Open()
    ' use a SQL Select command to retrieve the data from the Excel Spreadsheet
    ' the "table name" is the name of the worksheet within the spreadsheet
    ' in this case, the worksheet name is "Members" and is expressed as: [Members$]
    Dim objCommand As New OleDbCommand("SELECT * FROM [Sheet1$]", objXConn)
    Return objCommand


Please help..

Thanks.
Posted
Updated 14-Sep-11 22:40pm
v2

If you are using MS Excel 2007 than change Provider=Microsoft.Jet.OLEDB.4.0 to Microsoft.ACE.OLEDB.12.0 and Extended Properties=Excel 8.0 to
Extended Properties=Excel 12.0 in your connection string.

More details here.
 
Share this answer
 
v2
Comments
Abhinav S 15-Sep-11 4:49am    
Is the exact answer! 5.
AnnSJ 15-Sep-11 5:04am    
YEs it works..
Teh connection string i had initially was
Dim xConnStr As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\Arnold\Desktop\Annexcelweb\ExcelImport.xlsx;Extended Properties=Excel 12.0;HDR = YES;IMEX = 1"
n i tried changing it to
Dim xConnStr As String = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\Arnold\Desktop\Annexcelweb\ExcelImport.xlsx;Extended Properties=Excel 12.0;HDR = YES;IMEX = 1"
it didn work .. but when i changed it to the following :

Dim xConnStr As String = "Provider = Microsoft.ACE.OLEDB.12.0;" + "Data Source=C:\Users\Arnold\Desktop\Annexcelweb\ExcelImport.xlsx;" + "Extended Properties='Excel 12.0;HDR=Yes;'"

It worked.. Thanks Abhinav n suresh
You are probably trying to read an Excel 2007 file (xslx).
Try using the connection string described here[^].

Try something like "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Arnold\Desktop\Annexcelweb\ExcelImport.xlsx;Extended Properties=Excel 8.0;HDR = YES;IMEX = 1".
 
Share this answer
 
v2
Comments
Suresh Suthar 15-Sep-11 4:46am    
I forgot that article. Thanks Abhinav. 5!
Abhinav S 15-Sep-11 4:49am    
No problem. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900