Solved

ACE won't read Excel 2003 workbook

Posted on 2010-09-16
2
438 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

772 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

10 Experts available now in Live!

Get 1:1 Help Now