Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 16th, 2008, 02:58 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel to Access

Hi,

I have a form that will browse to an excel file... but what I can't seem to figure out is how to get the data into access...

I've tried the following with no luck...

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.xls;Extended Properties=Excel 8.0;HDR=YES;"

AND

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER=Microsoft Excel Driver (*.xls);DBQ=Server.MapPath('text.xls')"

Could someone shed some light?

Reply With Quote
  #2 (permalink)  
Old June 16th, 2008, 10:02 AM
Registered User
 
Join Date: Jun 2008
Location: , , United Kingdom.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have a look at...

http://p2p.wrox.com/topic.asp?TOPIC_ID=25073

I came across it while google'ing. I liked the look of the site that I registered and am now just browsing some of the posts.

hope it helps

Mych

I have not failed... I've just found 10,000 way that don't work!
Reply With Quote
  #3 (permalink)  
Old June 16th, 2008, 02:32 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default


Look here:
http://www.carlprothman.net/Default....orMicrosoftJet
(scroll down to the section that shows how to open Excel).

Thus:
Code:
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source=" & Server.MapPath("test.xls") & ";" _
        & "Extended Properties=""Excel 8.0;HDR=YES;"""

' do NOT forget the $ in the name of the sheet.  And the [...] *are* required
SQL = "SELECT * FROM [name of sheet$]" ' order by is optional, of course

Set RS = conn.Execute( SQL ) 
...
Reply With Quote
  #4 (permalink)  
Old June 18th, 2008, 10:17 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

This is good, but in both examples the file needs to be on the server itself... I've copied an excel file, and I am able to read it there using this:

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "DBQ=" & Server.MapPath("xl_data.xls") & ";" & _
  "DRIVER={Microsoft Excel Driver (*.xls)};"
Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open "SELECT * FROM [Sheet1$B4:C12];", cnnExcel, adOpenStatic, adLockPessimistic

But what I need, is that on the client side, through a form, they would specify an excel file, and I woudl ike to be able to read through THAT file...

Trying to create the connection hasn't been working for me...

cnnExcel.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=c:\xl_data.xls;" & _
         "Extended Properties=Excel 8.0;"

Reply With Quote
  #5 (permalink)  
Old June 18th, 2008, 10:28 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

FYI

This is the error message that I get:

Microsoft JET Database Engine error '80040e37'

The Microsoft Jet database engine could not find the object 'Sheet1$B4:C12'. Make sure the object exists and that you spell its name and the path name correctly.

/asp101_1.asp, line 40


This is line 40:
rstExcel.Open "SELECT * FROM [Sheet1$B4:C12];", cnnExcel, adOpenStatic, adLockPessimistic

But it works fine if the excel file is on the server...

Reply With Quote
  #6 (permalink)  
Old June 18th, 2008, 01:36 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ain't never going to happen.

Period.

NOTHING on the SERVER can EVER read any file (or other content) that is on the client. Period.

[Even if server and client are on same LAN, the server has to access the client via the LAN, *NOT* via HTTP.]

You would need to UPLOAD the Excel file to the server to make this work.

Why do you think browsers have all these incredible security features in place, if not to protect against just exactly things like this??? If the server *COULD* get to the Excel file on the client, it could also maliciously erase the file. Or erase lots of files. Or corrupt various operating system files.

Yes, servers and clients can "talk" more closely than what I have described, but ONLY if the clients INSTALL software that allows the closer connection. That is, either browser plugins or actual full applications. In general, what you are wanting to do should NOT be solved via a browser.
Reply With Quote
  #7 (permalink)  
Old June 18th, 2008, 01:43 PM
Friend of Wrox
 
Join Date: Mar 2004
Location: Ottawa, , Canada.
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you!

So uploading it is!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access and Excel help hewstone999 Access VBA 0 May 28th, 2008 05:26 AM
Excel to Access h@ckerz Access VBA 3 December 18th, 2006 10:32 AM
Excel via Access Vision G Access 2 June 1st, 2006 04:40 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM



All times are GMT -4. The time now is 10:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.