Wrox Programmer Forums
|
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 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 August 30th, 2004, 04:26 AM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default down load sql query as text file

 am new to asp, please help
i want to create a link, on clicking this link i want to download a sql query into text file.
i have done this as
/////////////////////////////////////////////////////////////
Response.Buffer = TRUE


Response.AddHeader "Content-Disposition","attachment;filename=text.txt"
Response.ContentType = "text/plain"
sql="select * from product_master"
set rs=con.execute(sql)

do until rs.eof
response.write(rs("product_name"))
response.write(rs("product_id"))
rs.movenext
loop
////////////////////////////////////////////////////////////////////
i want to display data from sql query as

product product_id
T-Shirt 101
Shirt 102

please help to do this. when i click on link it display File download dialog box and filename name "test.asp" instead of "text.txt" and then open in Macromedia Dreamweaver
Please help to do it in write way
Many Many Thank's in advanced


 
Old August 30th, 2004, 05:51 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I believe you would need to use the filesystem object, fairly sure you cant to it the way you have illustrated.

;;on clicking this link i want to download a sql query into text file
do you mean the results of the query into a text file

;;and then open in Macromedia Dreamweaver
I'm sure you have a good reason for opening a text file in DW, this is where you lost me. There is allot of working examples in google, go here and try one of the many.

You need something like:
-----------------------
Set FileSysObject = CreateObject("scripting.filesystemobject")
Set MyFile = FileSysObject.createtextfile("c:\text.txt", True)

Open your DB HERE

MyFile.Write DataString 'Put watever you want in the file here.

MyFile.Close
--------------------------




Wind is your friend
Matt
 
Old September 1st, 2004, 05:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Change the Content-Disposition header to inline, but keep the filename part - then it will display the text in the browser window
Response.AddHeader "Content-Disposition","inline;filename=text.txt"

I posted something about this curious behaviour a while ago http://p2p.wrox.com/topic.asp?TOPIC_ID=4005

rgds
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
cannot load the sql file to Godaddy Server EswaraPrakash BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 August 16th, 2007 04:08 PM
SQL QUERY RESULTS TO TEXT FILE ram33654 Classic ASP Basics 0 August 16th, 2006 09:20 PM
Readline From Text file and Use as Query phungleon Pro VB Databases 5 February 27th, 2004 10:01 AM





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