multiple download text files

S

Sunshine

I'm trying to break up this large query to download 2 or more files,
otherwise I recieve a memory error. I can't get the following code to write
to 2 different files. The error I get is because I try to
Response.AddHeader more than once. The query will return 190000 + records
and I am unable to download the data directly to the users computer due to
permissions. How do I get around this?

dim i
set Recordset1 = conn.execute("select * from table")

Dim F, Head Head = " "

For Each F In Recordset1.Fields
Head = Head & "," & F.Name
Next

Head = Mid(Head,3) & vbCrLf
Response.ContentType = "text/plain"
for i = 1 to 2
fn = "file" + cstr(i) + ".txt"
Response.AddHeader "Content-Disposition", "attachment; filename=" + fn
******* ERROR LINE ********
Response.Flush() Response.Write Head
Response.Write Recordset1.GetString(,50000,",",vbCrLf,"")
next

conn.Close
 
J

J. Baute

I'm guessing that calling GetString() is causing the error because it has to
return a huge string value to VBScript memory space.
Try looping over that recordset instead and write records line by line,
flushing every 1000 or so lines to the client to avoid the page from
appearing dead as it'll take a while to download this much data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top