Solved

Could not find installable ISAM.

Posted on 2011-03-01
8
425 Views
Last Modified: 2012-05-11
I receive the error message "Could not find installable ISAM." When I try to open an Excel file in my C# code behind of an aspx page. The code is:

// Create connection string variable. Modify the "Data Source"
        // parameter as appropriate for your environment.
        String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
            "Data Source=" + Server.MapPath("template.xlsx") + ";" +
            "Extended Properties=Excel 8.0;HDR=NO;IMEX=1";

        // Create connection object by using the preceding connection string.
        OleDbConnection objConn = new OleDbConnection(sConnectionString);

        // Open connection with the database.
        objConn.Open();

        // The code to follow uses a SQL SELECT command to display the data from the worksheet.

        // Create new OleDbCommand to return data from worksheet.
        OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM Sheet1", objConn);

        // Create new OleDbDataAdapter that is used to build a DataSet
        // based on the preceding SQL SELECT statement.
        OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();

        // Pass the Select command to the adapter.
        objAdapter1.SelectCommand = objCmdSelect;

        // Create new DataSet to hold information from the worksheet.
        DataSet objDataset1 = new DataSet();

        // Fill the DataSet with the information from the worksheet.
        objAdapter1.Fill(objDataset1, "ExcelData");

        // Bind data to DataGrid control.
        GridView2.DataSource = objDataset1.Tables[0].DefaultView;
        GridView2.DataBind();

        // Clean up objects.
        objConn.Close();
0
Comment
Question by:melli111
  • 4
  • 4
8 Comments
 
LVL 6

Expert Comment

by:PJBX
ID: 35011553
I think you should have apostrophes around the Extended Properties value. For example:

Change:
  "Extended Properties=Excel 8.0;HDR=NO;IMEX=1";
To:
  "Extended Properties='Excel 8.0;HDR=NO;IMEX=1'";
0
 
LVL 15

Author Comment

by:melli111
ID: 35012038
After completing this step, I received a different error.  This error is "External table is not in the expected format. "  I assume this means that the program thinks that the Excel table is not in the correct format, but I am positive that this table is a normal Excel 2007 file
0
 
LVL 6

Expert Comment

by:PJBX
ID: 35012327
Oh. The template.xlsx in your connection string. You need to use another provider.

For 2007
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\TestWorkbook.xlsx;Extended Properties="Excel 12.0;HDR=YES;"

Also see:
http://www.connectionstrings.com/excel-2007
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 15

Author Comment

by:melli111
ID: 35017045
Thank you.  The error is now pointing to the line "objAdapter1.Fill(objDataset1, "ExcelData");" Saying that "The Microsoft Office Access database engine could not find the object 'Sheet1'.  Make sure the object exists and that you spell its name and the path name correctly. "
0
 
LVL 6

Expert Comment

by:PJBX
ID: 35022746
Confirm the Sheet Names in your wookbook.
Confirm the path (Server.MapPath("template.xlsx") ) is correct
0
 
LVL 15

Author Comment

by:melli111
ID: 35026951
I am 100% positive that the name in the Workbook is Sheet1.  The path could be causing the error.  I have the Excel file right in the same folder as the solution in Visual Studio.  When I try to move the Excel file to a folder like the C:\ drive, I receive an error that the path is not a valid Virtual path.
0
 
LVL 6

Accepted Solution

by:
PJBX earned 500 total points
ID: 35030118
Is the template.xlsx in the root or in a folder?

Here is an example of what I'm doing. I have my files in the XLSData folder. Look at the FilePath variable.
      Dim FilePath As String = "~/XLSData/" & strFileName
        Dim connString As [String] = ("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=") & Server.MapPath(FilePath) & ";Extended Properties='Excel 8.0;IMEX=1'"
        'Dim connString As String = ("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=") & Server.MapPath(FilePath) & Chr(34) & ";Extended Properties=Excel 8.0;" & Chr(34)
0
 
LVL 15

Author Comment

by:melli111
ID: 35030686
I received a new error message when the follong line of code executes "objConn.Open();".  the error message reads

The Microsoft Office Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now