Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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";
bk.WriteToServer(dr);
xlcon.Close();
Posted 8-Oct-12 1:46am

1 solution

Rate this: bad
good
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.
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,680
2 CPallini 4,850
3 George Jonsson 3,454
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
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