Вы просто сбросили бы результаты своего SQL в набор записей adodb, как у вас уже есть, затем перебрали набор записей и записали файл csv, используя объект fso com.
Пример кода (не проверено)
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