Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ACE won't read Excel 2003 workbook

Posted on 2010-09-16
2
Medium Priority
?
448 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

610 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