Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 15th, 2006, 11:53 AM
Registered User
Join Date: Jun 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem exporting to excel

I'm query an access database, which is working fine displaying as web content. I would like to export the results to excel, and basically just added the lines below to the one displaying to the web

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"

I have the code below, which does not give errors, but produces an empty exel file. the only thing it produces are the table headings and the links Any ideas?

<%@ Language=VBScript %>
<%Option explicit
Dim oRs,oRs2, conn, conn2, connect, strSQL, count, oddeven, bgcolor

set conn=server.CreateObject("ADODB.connection")
set conn2=server.CreateObject("ADODB.connection")

connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("sheep.mdb") & ";Persist Security Info=False"
conn.Open connect
conn2.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("info.mdb") & ";Persist Security

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Enquiry_List.xls"

<center>Search Results</center><br>
<table border=1 cellspacing=0 cellpadding=3>
<tr bgcolor="#ADD8E6">
<td nowrap><b>1</b></td>
<td nowrap><b>2</b></td>
<td nowrap><b>3</b></td>



    Set oRs=server.CreateObject("adodb.recordset")

    strSQL = "SELECT DISTINCT * FROM tblInfo WHERE Name= '" & request("name") & "'AND Description = '" &

request("description") & "'AND Location = '" & request("location") & "' "

    oRs.Open strSQL, conn2

    Do while not oRs.EOF

    select case oddeven
    case "1","3","5","7","9"
    bgcolor = "#E8E8E8"

    case else
    bgcolor = "#FFFFFF"
    end select

    Response.Write "<tr bgcolor='" & bgcolor & "'><td nowrap> " & oRs ("Name") & "</td><td nowrap>" & oRs ("Description") & "</td><td nowrap>" & oRs ("Location") & "</td></tr>"


    Set oRs = Nothing


<a href="sheepexcel.asp">[Export to Excel]</a>
<center><a href="sheepquery.asp">[Search for another product]</a> <a href="index.htm">[Home]</a></center>

Reply With Quote
  #2 (permalink)  
Old June 15th, 2006, 12:55 PM
Registered User
Join Date: Jun 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

i tested with a
Response.Write "<tr><td nowrap>blah</td></tr>"

i can get that to to show up in the Excel except for inside the

Do while not oRs2.EOF

Reply With Quote

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
Problem in exporting crystal report to excel. yasinirshad .NET Framework 1.x 0 June 11th, 2008 02:20 AM
Problem in exporting data from datagrid to Excel deb_kareng ASP.NET 2.0 Professional 4 August 4th, 2007 09:21 AM
problem in exporting datagrid to excel swati_joshi ASP.NET 1.0 and 1.1 Professional 3 June 4th, 2006 11:26 PM
Exporting data to excel from datagrid, Problem. swadhinm ASP.NET 1.x and 2.0 Application Design 0 May 31st, 2005 01:44 AM
problem exporting datagrid to excel kscdave Classic ASP Professional 0 March 29th, 2005 11:57 AM

All times are GMT -4. The time now is 12:51 AM.

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