jrthor2
04-17-2003, 05:31 AM
Is there a way to take a page that shows all ou my churches members (pulled from an Access database) and export/save the results to a text file?
Thanks.
Thanks.
|
Click to See Complete Forum and Search --> : export to txt file jrthor2 04-17-2003, 05:31 AM Is there a way to take a page that shows all ou my churches members (pulled from an Access database) and export/save the results to a text file? Thanks. jrthor2 04-17-2003, 07:43 AM And how would I go about doing this? I am pretty new to ASP. jrthor2 04-17-2003, 07:47 AM It would probably be more efficient if it could be saved on the users computer. Thanks! potemkin 04-22-2003, 08:23 PM Do you want to export the text into an existing TXT file, or do you want to script to make you a new TXT file? Well anyways, this is how you do it with the creation of a new TXT file: set makelist = createobject("scripting.filesystemobject") Set writetolist = makelist.createtextfile(server.mappath(whatever.txt), true) writetolist.writeline(Select SQL String Here) writetolist.Close If this won't work, just post the error here, and I will try to make it work. If it did work then you can, of course, make this script much more dynamic. Cheers! jrthor2 04-23-2003, 07:22 AM is it possible to export it to a comma delimited file with just the database results, not all of the html? jrthor2 04-23-2003, 07:27 AM potemkin, This is how I set up my code: Select Case True Case (order="MembershipDate" Or _ order2="MembershipDate") strOrderBy = "MembershipDate" SQLstmt = "SELECT * FROM MemberList ORDER BY MembershipDate Desc , LastName Asc" Case (order="DateLastTalked" Or _ order2="DateLastTalked") strOrderBy = "DateLastTalked" SQLstmt = "SELECT * FROM MemberList ORDER BY DateLastTalked Desc , LastName Asc" Case (Request.queryString("order") = "" And _ trim(Request.Form("searchtxt")) <> "") SQLstmt = "SELECT * FROM MemberList WHERE LastName like '" & searchtxt & "%'" & _ " ORDER BY LastName,FirstName" Case (Request.queryString("order") = "" And _ trim(Request.QueryString("searchtxt")) <> "") SQLstmt = "SELECT * FROM MemberList WHERE LastName like '" & searchtxtq & "%'" & _ " ORDER BY LastName,FirstName" Case (Request.Querystring("order") = "" Or _ Request.queryString("order") = "Lastname" Or _ Request.Form("order") = "LastName") strOrderBy = "Lastname" SQLstmt = "SELECT * FROM MemberList ORDER BY LastName,FirstName Asc" Case (trim(Request.QueryString("sortby"))<>"") sortby=trim(Request.QueryString("sortby")) strOrderBy = orderpg SQLstmt = "SELECT * FROM MemberList WHERE LastName like '" & sortby & "%'" & _ " ORDER BY LastName,FirstName" End Select //Response.Write(SQLstmt) Set objPagingRS = Server.CreateObject("adodb.recordset") objPagingRS.PageSize = iPageSize objPagingRS.CacheSize = iPageSize ' Open RS objPagingRS.Open SQLstmt,conn,3,3 TotalMembers = objPagingRS.Recordcount set makelist = createobject("scripting.filesystemobject") Set writetolist = makelist.createtextfile(server.mappath(members.txt), true) writetolist.writeline(SQLstmt) writetolist.Close I get the error: Microsoft VBScript runtime error '800a01a8' Object required: 'members' /Members/index.asp, line 162 Line 162 is: Set writetolist = makelist.createtextfile(server.mappath(members.txt), true) I don't want to save it on the server, I want the person to be able to click a link "Download full member list". jrthor2 04-23-2003, 07:38 AM How do I get my results in to string seperated by a comma? jrthor2 04-23-2003, 07:50 AM In the code you supplied, what do i use for filename? do I need to save this txt file to the server first, and then use that filename there? Sorry, not quite following. This is all pretty new to me. Thanks jrthor2 04-24-2003, 07:25 AM Ok, this is what I have. On my index.asp page, I have a link that says "Download to csv file". Tha link looks like this: http://www.server.com/members/download_txt.asp?download=y I have attached the download_txt.asp file. I am getting this error: ADODB.Connection error '800a0e78' Operation is not allowed when the object is closed. /Members/download_txt.asp, line 24 Line 24 is: Do While Not rsDownload.EOF I'm not sure my download_txt.asp file is correct. Could you look at it and help. Thanks!! jrthor2 04-24-2003, 08:18 AM oops, stupid mistake. Well, I'm not sure I am even doing this right, am I. could you maybe show me the best way to have a link on my index page and when you click it, it prompts to download the text file that has all my members in it, generated from an access database? I really appreciate all your help. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |