Solved

ACE won't read Excel 2003 workbook

Posted on 2010-09-16
2
440 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

862 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now