Take the 2-minute tour ×

Here's my code which is in the beginning of a method for converting .xls file to .csv.


string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sourceFile + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\"";

OleDbConnection conn = new OleDbConnection(strConn);


And it crashes on the last line, throwing this exception: Unexpected error from external database driver (22).

I tried removing the IMEX=1 part, but it still didn't work.

What is the problem?

share|improve this question
Can you provide us that myFile.xls ? –  yogi Feb 7 '13 at 8:04
@yogi It's an excell file with one sheet. The first row has two columns, and all the next have 9 columns. The cells have a background color. –  petko_stankoski Feb 7 '13 at 8:07
add comment

4 Answers

I also had the same issue but I had to rename the spreadsheet to a shorter name, then it worked.(SQL 2012 Dev)

share|improve this answer
add comment

Try to use Microsoft.Jet.OLEDB.4.0 provider. Also I would advise you to use OleDbConnectionStringBuilder to build OleDbConnectionString:

var oleConnectionStringBuilder = new OleDbConnectionStringBuilder { Provider = "Microsoft.Jet.OLEDB.4.0" };
oleConnectionStringBuilder.DataSource = sourceFile;
oleConnectionStringBuilder.Add("Extended Properties", "Excel 8.0");
oleConnectionStringBuilder.Add("HDR", "No");
share|improve this answer
With using your code I get Could not find installable ISAM. error. –  petko_stankoski Feb 7 '13 at 8:11
@petko_stankoski Here is discussing about this error: stackoverflow.com/questions/4214527/… –  Andrey Gordeev Feb 7 '13 at 8:15
@petko_stankoski, this thread contains possible solution too: social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/… –  Andrey Gordeev Feb 7 '13 at 8:16
add comment

It seems that there is something wrong with the Microsoft Excel Driver. Try to execute the program in another PC to see whether this error happens.

Please take a look at this KB article:

http://www.codeproject.com/KB/database/ReadExcel07.aspx . You can use OleDb to connect the Excel file.

I hope this can help you and feel free to follow up after you have tried.

share|improve this answer
Which program do I need to execute on another pc? –  petko_stankoski Feb 7 '13 at 8:33
Your application, and keep the file on that PC. –  Igoy Feb 7 '13 at 8:35
No it didnt work there either. –  petko_stankoski Feb 7 '13 at 8:36
add comment
up vote 0 down vote accepted

Strangely enough, I replaced the file in another folder and it worked. I have no idea why this is happening.

share|improve this answer
add comment

Your Answer


