Code Comments
Programming Forum and web based access to our favorite programming groups.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.
Post Follow-up to this messageWhy 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. > > >
Post Follow-up to this messageYes, 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.
>
>
>
Post Follow-up to this messageThanks 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 > >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.