Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 29th, 2004, 05:07 PM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Importing Excel to screen with ASP

Having loads of troubles with this.

Heres the code I have now...

PHP Code:
Test
<%
'## Create Connection and Recordsets
[s][s][s][s]Dim Conn, RS[/s][/s][/s][/s]
[s][s][s][s]Set Conn = CreateObject("ADODB.Connection")[/s][/s][/s][/s]
[s][s][s][s]Set RS = CreateObject("ADODB.Recordset")[/s][/s][/s][/s]
'
## The Data to extract
[s][s][s][s]szSQL "select * from 'EM JULY-04'"[/s][/s][/s][/s]
'## Create and open the connection
[s][s][s] [/s][/s][/s]
[s][s][s][s]Conn.Open "Driver={Driver do Microsoft Excel(*.xls)};" & "DBQ=" & Server.MapPath("test.xls") & ";"[/s][/s][/s][/s]
'
## set the cursor to be static.
[s][s][s][s]rs.cursortype ' adStatic.[/s][/s][/s][/s]

'
## open the recordset
[s][s][s][s]rs.open szSQLConn[/s][/s][/s][/s]

'## Disconnect recordset, eliminate connection
[s][s][s][s]rs.activeconnection = nothing[/s][/s][/s][/s]
[s][s][s][s]Conn.Close[/s][/s][/s][/s]
[s][s][s][s]Set Conn=nothing[/s][/s][/s][/s]
'
## iterate through the recordset.
'while not rs.eof
'  
response.write RS("name") & " -- "
'  response.write RS("location")  & " -- "
'  
response.write RS("Coordinator")  & " -- "
'  response.write RS("Date")  & " -- "
'  
response.write RS("Time")  & "<BR>"
'  rs.movenext
'
wend
RS
.close
Set RS
=nothing
%> 
Page is just coming up as 500 internal server error. im not even able to see the "Test Hi" listed at the begining of the page. Anyone got any ideas of what needs to be changed or added. Just trying to do a simple read excel and display to screen. As i've never done this before im a bit clueless as to the correct connection string or whatever else i may need.

 
Old March 30th, 2004, 04:46 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default

Hi

I created a blank sheet with and used your code, the only change I made was to close the connections after looping through the recordset and also the query (Code Below) Do you get any other error thats more specific about what the problem is e.g Line # or something?

<%
'## Create Connection and Recordsets
    Dim Conn, RS
    Set Conn = CreateObject("ADODB.Connection")
    Set RS = CreateObject("ADODB.Recordset")
'## The Data to extract
    szSQL = "select * from [Sheet1$]"
'## Create and open the connection

    Conn.Open "Driver={Driver do Microsoft Excel(*.xls)};" & "DBQ=" & Server.MapPath("Book2.xls") & ";"
'## set the cursor to be static.
    rs.cursortype = 3 ' adStatic.

'## open the recordset
    rs.open szSQL, Conn
'## iterate through the recordset.
while not rs.eof
  response.write RS("name")
  rs.movenext
wend
RS.close
Set RS=nothing
Conn.Close
Set Conn=nothing
%>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing a Range from Excel JezLisle Access VBA 0 July 27th, 2007 02:54 AM
Importing Excel sheet into Access using ASP prasanta2expert ASP.NET 1.0 and 1.1 Basics 1 October 5th, 2006 02:36 PM
Importing from Excel bmains ADO.NET 1 October 9th, 2004 11:44 AM
importing Excel into Oracle using VB hagit Oracle 0 January 21st, 2004 07:53 PM
MS Excel(Importing) S Kamran Access 1 October 29th, 2003 06:55 AM





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