Pages

Saturday, October 25, 2008

C# Excel OLEDB and Could not find installable ISAM

So you have chosen to manipulate Excel spreadsheets with C#, and rather than using Excel Automation you are using OLEDB. Now you find you receive "Could not find installable ISAM" when bebugging.

I will bet it has to do with escaping the quotes surrounding the "Extended Properties" in your connection string. Personally, things worked fine for me util I added the HDR or IMEX variables.

The Excel references at www.connectionstrings.com are very helpful and indicate the quotes are an issue, but don't provide specific working examples.

Here you are:

String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Test.xls;Extended Properties=\"Excel 8.0;HDR=No;IMEX=1;\"";

or maybe more helpfully:

String sFile = "C:\\Test.xls";

String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sFile + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1;\"";


Notice the \" escapes surrounding Excel 8.0;HDR=No;IMEX=1;

Hope that helps.

7 comments:

  1. Thank you friend. It was very helpful to me and solved my connectivity problem. Thanks a lot.

    ReplyDelete
  2. Very helpful! Thanks for the tip!

    ReplyDelete
  3. vey very helpful. i was searching for this for a long time.

    ReplyDelete
  4. Thank you very very much, indeed this was helpful.

    ReplyDelete
  5. Thanks a lot, It was very useful

    ReplyDelete
  6. RAJANI BOBBA(Anblicks)7/30/2012 03:05:00 AM

    Thanks a Lot..... It was very useful

    ReplyDelete
  7. Thanks a TON for this post !Very Helpful.

    ReplyDelete