Solved

Could not find installable ISAM.

Posted on 2011-03-01
8
435 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

697 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