Solved

Could not find installable ISAM.

Posted on 2011-03-01
8
418 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 15

Author Comment

by:melli111
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 6

Expert Comment

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

Author Comment

by:melli111
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

744 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

20 Experts available now in Live!

Get 1:1 Help Now