Solved

ACE won't read Excel 2003 workbook

Posted on 2010-09-16
2
443 Views
Last Modified: 2013-12-16
Hi -
I'd like to read an Excel 2003 (.xls) (not xlsx) workbook, and at this point I am wondering if it is possible.  

Using the following connection string and code:
string cnstr = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=c\:mytext.xls;Extended Properties=Excel 12.0;"
DataTable dt = new DataTable();
OleDbDataAdapter cmd = new OleDbDataAdapter("SELECT * FROM [IR Database$A4:IV18] ", cnstr);
cmd.Fill(dt);

I get the message:
"The Microsoft Office Access database engine could not find the object 'IR Database$A4:IV18'.  Make sure the object exisits and that you spell its name and path name correctly.

I've changed "Extended Properties=Excel 12.0" to "Extended Properties=Excel 8.0" and get the same result.

The Jet connection string works fine, but not on a 64 bit Server (via a CLR).  

Interestingly the OpenRowSet in SQL works fine ...
SELECT * Into #tempPool FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0;Database=\\server\Pool.xls;ReadOnly=True;IMEX=1', SELECT * FROM [FacilityPoolMap$]')

Makes me wonder if I need to install the 64x ACE Driver (installed on the server) on my development machine.

Suggestions are appreciated.

Thanks Mark
0
Comment
Question by:MarkMahon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 33698778
Since there are no 64-bit OleDb drivers for anything other than SQL Server, therefore, we cannot write 64-bit apps which interface with databases directly.

What you need to do is split your application into a 32 bit part and a 64 bit part, use COM interop to cross the 64/32 bit boundary. For instance, drop the code (just a simple class library compiled as 32 bit) that retrieves the Excel data into a COM+ (System.EnterpriseServices) as a "server type" application, and call that server methods from your 64 bit Windows service. This is exactly why System.EnterpriseServices are made for.

There is already request sent to the product group to ask for 64-bit JET provider for x64 OS. You can check the following link for more information.

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=125117

Comment found at http://forums.asp.net/p/1128266/1781961.aspx
0
 

Accepted Solution

by:
MarkMahon earned 0 total points
ID: 33706237
Well with a little playing around I found out the the problem is with the sheetname$range:  "IR Database$A4:IV18."  (just the error message said).  While the grammer worked in JET it apparantly doesn't for ACE.

So I changed defined a range name and used it: "irTable".

So
  OleDbDataAdapter cmd = new OleDbDataAdapter("SELECT * FROM [IR Database$A4:IV18] ", cnstr);
was changed to
  OleDbDataAdapter cmd = new OleDbDataAdapter("SELECT * FROM [rTable] ", cnstr);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question