views:

246

answers:

3

I have the following code from a legacy app which currently reads from an excel 2003 spreadsheet on a server, but I need this to run from my machine which uses excel 2007. When I debug on my machine ADO does not seem to be reading the spreadsheet. I have checked all file paths etc. and location of spreadsheet that is all fine. I've heard that you cannot use the jet db engine for excel 2007 anymore? Can someone confirm this? What do I need to do to get this to work? Please help!

set obj_conn = Server.CreateObject("ADODB.Connection")
obj_conn.Open   "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & Application("str_folder") & "CNS43.xls;" & _
            "Extended Properties=""Excel 8.0;"""
set obj_rs_cns43 = Server.CreateObject("ADODB.RecordSet")
obj_rs_cns43.ActiveConnection = obj_conn
obj_rs_cns43.CursorType = 3
obj_rs_cns43.LockType = 2
obj_rs_cns43.Source = "SELECT * FROM [CNS43$]"
obj_rs_cns43.Open
+1  A: 

Try changing your connection string like this (source article):

obj_conn.Open   "Provider=Microsoft.ACE.OLEDB.12.0;" & _ 
            "Data Source=" & Application("str_folder") & "CNS43.xls;" & _ 
            "Extended Properties=""Excel 12.0;""" 
RedFilter
I have tried that already, but it didn't work, does this driver need to be installed or should it be installed automatically?
jeff
I resolved this issue, the problem I was having was related to 64 bit OS compatibility with the microsoft Ace drivers. To get this to debug you have to force Visual Studio to debug with 32 bit i.e. debug config manager.
jeff
A: 

You can always use Excel Automation to read from Excel. But I think that's the Plan B.

The best solution for this problem would be Openrowset. No ASP required, just pure SQL.

Here's a "Closer to Excel" article

Alexander
can i use the SQL within the ASP page?
jeff
You can access a database from ASP, can you? If you can write queries then it's no more a problem related to ASP, because it can be written in SQL, and SQL is accessible from almost all languages.
Alexander
A: 

I resolved this issue, the problem I was having was related to 64 bit OS compatibility with the microsoft Ace drivers. To get this to debug you have to force Visual Studio to debug with 32 bit i.e. debug config manager.

jeff