?
Solved

ACE won't read Excel 2003 workbook

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

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
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…

777 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