0

I am using OLEDB to read information from one excel file and output it to another file in a different format. While the queries executed on the first excel file return properly, when I attempt to execute an insert query on the second file, vshost32.exe crashes when connection.Open() is called. There is an InvalidOperationException thrown on the ServerVersion of OleDBConnection when it is created, which I assume is normal, as it changes to a valid version number, and the state changes from Closed to Open when Open() is called on the connection.

Here are the connection strings that I am attempting to use. The first one is used for the first excel file, while the following one is used for writing to the output. The only discernible difference is the addition of the "ReadWrite" mode to the second string. I have also tried changing "Excel 8.0" to "Excel 12.0" in the Extended Properties.

connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                inputFile + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";

connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                outputFile + ";Mode=ReadWrite;Extended Properties=\"Excel 8.0;HDR=YES;\"";
Anonymous
  • 1
  • 2
  • You seem to be missing a `;` after `inputfile`. Alternatively your `outputfile` had an additional `;` – Pynner Jan 30 '12 at 03:09
  • Thanks for pointing that out. It was just a late night with copy and pasting. It appears that the issue was rooted in the fact that I did not have the file open for editing? I was not aware that it must be open for OLEDB to access its contents. – Anonymous Jan 30 '12 at 20:12

0 Answers0