Home > Archive > ASP > October 2004 > CSV Download
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Simon Harris 2004-10-26, 8:55 pm |
| Hi All,
I have created a script which connects to a SQL DB, runs a query, writes the
results out to a file (Using FSO) then presents the user with a link to
download the CSV.
As the file contains sensitive data, I dont want to leave the file on the
server, and I dont want to rely on the user to delete the file after every
export.
Does anyone have any suggestions?
Thanks,
Simon.
| |
| Manohar Kamath 2004-10-26, 8:55 pm |
| Why not stream the contents of the file, instead of creating a file and
letting the user download it? So, instead of writing using FSO, you write it
out to the response object. Just make sure you change the content type to
reflect the CSV download:
<%
Response.ContentType = "text/csv"
%>
--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Simon Harris" <too-much-spam@makes-you-fat.com> wrote in message
news:OwlT$b6uEHA.3624@TK2MSFTNGP09.phx.gbl...
> Hi All,
>
> I have created a script which connects to a SQL DB, runs a query, writes
the
> results out to a file (Using FSO) then presents the user with a link to
> download the CSV.
> As the file contains sensitive data, I dont want to leave the file on the
> server, and I dont want to rely on the user to delete the file after every
> export.
>
> Does anyone have any suggestions?
>
> Thanks,
> Simon.
>
>
>
| |
| Ray Costanzo [MVP] 2004-10-26, 8:55 pm |
| Yes, do not ever create the file! :]
<%
set oADO = CreateObject("ADODB.Connection")
oADO.Open YourConnectionSTring
Set oRS = oADO.Execute("Your query")
sCSV = oRS.GetString(2,,",",vbCrLf,"")
oRS.Close : Set oRS = Nothing
oADO.Close : Set oADO = Nothing
Response.ContentType = "Simon's CSV File"
Response.AddHeader "Content-Disposition","attachment;
filename=sensitiveData.csv"
Response.Write sCSV
%>
Ray at work
"Simon Harris" <too-much-spam@makes-you-fat.com> wrote in message
news:OwlT$b6uEHA.3624@TK2MSFTNGP09.phx.gbl...
> Hi All,
>
> I have created a script which connects to a SQL DB, runs a query, writes
> the results out to a file (Using FSO) then presents the user with a link
> to download the CSV.
> As the file contains sensitive data, I dont want to leave the file on the
> server, and I dont want to rely on the user to delete the file after every
> export.
>
> Does anyone have any suggestions?
>
> Thanks,
> Simon.
>
>
>
| |
| Simon Harris 2004-10-26, 8:55 pm |
| Thanks Manohar, sounds like a good idea - I guess I would create the CSV in
memory by building a string, then pump it all to the browser?
"Manohar Kamath" <mkamath@TAKETHISOUTkamath.com> wrote in message
news:%23Wjosn6uEHA.2616@TK2MSFTNGP10.phx.gbl...
> Why not stream the contents of the file, instead of creating a file and
> letting the user download it? So, instead of writing using FSO, you write
> it
> out to the response object. Just make sure you change the content type to
> reflect the CSV download:
>
> <%
> Response.ContentType = "text/csv"
> %>
>
> --
> Manohar Kamath
> Editor, .netWire
> www.dotnetwire.com
>
>
> "Simon Harris" <too-much-spam@makes-you-fat.com> wrote in message
> news:OwlT$b6uEHA.3624@TK2MSFTNGP09.phx.gbl...
> the
>
>
|
|
|
|
|