Solved

Could not find installable ISAM.

Posted on 2011-03-01
8
449 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
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
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

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.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

696 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