Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7541145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:49:05+00:00 2026-05-30T07:49:05+00:00

I am not really familiar with asp-classic functions, though i am now working with

  • 0

I am not really familiar with asp-classic functions, though i am now working with a .asp file that displays records from a SQL database upon a java-script onChange event in a drop-down menu. What I’m trying to achieve is to display these records in the format below, and for all of them to be written to a text file without being called through java-script even from the drop-down menu.

Here’s what I’m working with so far:

<!--#include virtual="/includes/functions.asp" -->
<%
intBusiness_Catagory = Request("select_catagory")

Set thisConn    = Server.CreateObject("ADODB.Connection")
thisConn.Open CreateAfccDSN()

SelectSQL   = "SELECT * FROM BusinessInfo WHERE ((CatID = " & intBusiness_Catagory & ") or (CatID2 = " & intBusiness_Catagory & ") or (CatID3 = " & intBusiness_Catagory & ")) and (intStatusCodeID = 1) and (intOnWeb = 1) Order By vcBusinessName"
Set SelectRs = thisConn.Execute(SelectSQL)


If SelectRs.EOF Then
    Response.Write("No members found for selected category.<br> Please search <a href='javascript:history.back()'>again</a>.")
Else
%>
<b>Member Search Results:</b>
<p>

<%
End If

    If Not SelectRs.BOF AND Not SelectRs.EOF then
        SelectRs.MoveFirst
        Do Until SelectRs.EOF
%>
            <b><%=SelectRs("vcBusinessName") %></b><br>
            <%=SelectRs("vcPhone") %><br>
            <%=SelectRs("vcPAddress") %><br>
            <%=SelectRs("vcPCity") %>, <%=SelectRs("vcPState") %>&nbsp;&nbsp;<%=SelectRs("vcPZipCode") %><br>
            <%
            If isNull(SelectRs("vcURL")) then

            Else
            %>
                <b>Website: </b><a href="http://<%=SelectRs("vcURL") %>" target="_blank"><%=SelectRs("vcURL") %></a>
            <%
            End If
            %>
            <p>
            <hr>
<%
            SelectRs.MoveNext
        Loop
%>

<%
    End If

SelectRs.Close
Set SelectRs = Nothing
%>

<p style="text-align: right"><small><a href="business_directory_framed.asp">Back to directory index</a></small></p>

Anyone can assist with a solution to this? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:49:07+00:00Added an answer on May 30, 2026 at 7:49 am

    You’d simply dump the results of your SQL into an adodb recordset as you already have, then loop through the recordset and write the csv file using the fso com object.

    Example Code (untested)

        dim fs, HeadersRow, TempRow, objFolder, DateStr
    
    '#### Buld a NTFS safe filename based on Date
        DateStr = now()
        DateStr = Replace(DateStr, "/", "_")
        DateStr = Replace(DateStr, ":", "_")   
    
    '#### Initalise FileSystemObject
        Set fs = Server.CreateObject("Scripting.FileSystemObject") 
    
    '#### Delete any old Report_ files (optional
        Set objFolder = fs.GetFolder(Server.MapPath("Reports"))
    
        For Each objFile in objFolder.Files
            FileName = objFile.Name
            if left(FileName,7) = "Report_" then
                if fs.FileExists(Server.MapPath("Reports") & "/" & FileName) then
                    on error resume next
                        fs.DeleteFile(Server.MapPath("Reports") & "/" & FileName)
                    on error goto 0
                end if
            end if
        Next
        Set objFolder = Nothing
    
    '#### Create a Uniquqe ID for this report
        NewFileName = "Report_" & DateStr & ".csv"
    
    '#### next, get the Query and Populate RS
        SQL = "SELECT * FROM whatever"
        SET RS = db.Execute(SQL)
    
    '#### WE now have a RS, first we need the column headers:
        For fnum = 0 To RS.Fields.Count-1
            HeadersRow = HeadersRow & "," & RS.Fields(fnum).Name & ""
        Next
    
    '#### The loop will have made a string like: ,"col1", "col2", "col3", "col4"
    '#### Remove the leading comma ,
        dim LengthInt
        LengthInt = len(HeadersRow)
        HeadersRow = right(HeadersRow, LengthInt - 1)
    
    '#### Dump the headers to the CSV Report
        OutputToCsv HeadersRow, NewFileName
        TempRow = ""
    
    '#### now loop through all the data and dump in CSV report too
        Do Until RS.EOF
    
            TempRow = ""
    
            For fnum = 0 To RS.Fields.Count-1
                TempRow = TempRow & "," & RS.Fields(fnum).Value & ""
            Next
    
            '#### Again, remove the leading comma, then send to CSV
                LengthInt = len(TempRow)
                TempRow = right(TempRow, LengthInt - 1)
                OutputToCsv TempRow, NewFileName
    
            RS.MoveNext
        Loop
    
    '#### Functions
    function OutputToCsv (strToWrite, FileName)
        '#### Simple function to write a line to a given file
        '#### Not the most efficent way of doing it but very re-usable
        dim fs
        Set fs=Server.CreateObject("Scripting.FileSystemObject") 
        If (fs.FileExists(server.MapPath("\") & "\Reports\" & FileName))=true Then
            set fname = fs.OpenTextFile(server.MapPath("\") & "\Reports\" & FileName, 8, True)
        Else
            set fname = fs.CreateTextFile(server.MapPath("\") & "\Reports\" & FileName,true)
        End If        
        fname.WriteLine(strToWrite)
        fname.Close
        set fname=nothing
        set fs=nothing
    end function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not really familiar with jQuery. I have this code that I downloaded
Let me start by saying that I'm a linux guy and not really familiar
I'm not really familiar with creating generic methods, so I thought I'd put this
i'm really not very familiar with CSS and HTMl so take it easy with
I'm not too familiar with Linux/Bash, so I can't really find the right terms
So I am not really familiar with the java String methods and I am
I'm writing a java binding for a C code and I'm not really familiar
OK, first off, I am NOT really familiar with javascript, so please forgive if
I'm having an issue with flash, which I am not really familiar with. I'm
I have this code in the asp.net application start evert, and I'm not really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.