Click here to Skip to main content
13,198,068 members (64,489 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am Trying to convert Excel Doc to database I m using framework 3.5 and sql express 2008, when I m trying to run it is giving me following Exception :

"Could not find installable ISAM.."

the code I M using is :

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Homeconstr"].ConnectionString);
string path = FileUpload1.FileName.ToString();
string xlconst = @"Data Source=" + path + ";Provider=Microsoft.ACE.OLEDB.12.0; Extended Properties=Excel 12.0;";
OleDbConnection xlcon = new OleDbConnection(xlconst);
OleDbCommand xlcom = new OleDbCommand("Select * from [Sheet1$]", xlcon);
xlcon.Open(); //Exception Occuring here
OleDbDataReader dr;
dr = xlcom.ExecuteReader();
SqlBulkCopy bk = new SqlBulkCopy(con);
bk.DestinationTableName = "emp_tracker";
Posted 8-Oct-12 1:46am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First, the path variable would just contain file name and not the full path. For that you would have to use Server.MapPath instead to resolve the path of the uploaded file. Which means you would have to store the uploaded Excel files in a specific location on the server and only then you can do a Server.MapPath.

Second, for your specific error this is what Microsoft has to say about it: Could not find installable ISAM[^]

Finally, as a suggestion, try not using this approach to import Excel data because you cannot guarantee if Excel would be installed on the server. This code would need Excel installed on the server to work. As an alternative, I prefer copying and pasting Excel data into a text box and on the submit or save button click, parse this delimited data into a list and then iterate over it saving each record to the database. This way you can easily control the execution and provide more robust error handling mechanism.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100