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. Anonymous1:59 AM

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

    ReplyDelete
  2. Anonymous3:58 PM

    Very helpful! Thanks for the tip!

    ReplyDelete
  3. Anonymous5:24 PM

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

    ReplyDelete
  4. Anonymous1:55 PM

    Thank you very very much, indeed this was helpful.

    ReplyDelete
  5. RAJANI3:04 AM

    Thanks a lot, It was very useful

    ReplyDelete
  6. RAJANI BOBBA(Anblicks)3:05 AM

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

    ReplyDelete
  7. Anonymous6:21 AM

    Thanks a TON for this post !Very Helpful.

    ReplyDelete