473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to Download Secure Statement

JJ
Hi,

I have written a web app in asp3 which is used by lots of users.
The data is all held server side.
However, I want it so that the users can export the data in a csv file, much
like you can download a statement from online banking.

However, I don't want to save the file to the server, as then anyone else
might guess the filename and download it.
Is there any way to directly generate a file from an asp script. i.e.
instead of asp returning html, it returns csv data which the user can save
away.

Many Thanks in Advance

JJ
Jul 19 '05 #1
1 1260
Here is a function that exports a csv or tab delimited using adodb stream..
It enumerates fields in a db so does not need much conversion
<%
'We got this far so validation is acheived
fncExportStockUnits SQLtemp, SQLFrom, SQLWhere, SQLOrder
%>
<%
Sub fncExportStockUnits(TheSQLtemp,TheSQLFrom,TheSQLWh ere,TheSQLOrder)
Set orsExp = Server.CreateObject("ADODB.Recordset")
orsExp.cursorlocation = adUseClient
orsExp.open TheSQLtemp & TheSQLFrom & SQLWhere & TheSQLOrder, oconn,
adOpenForwardOnly, adLockReadOnly, adCmdText
For iFldCount = 0 To orsExp.Fields.Count - 1
sColName = sColName & LCase(orsExp(iFldCount).Name) & ","
Next
sHeader = "rec_num" & sDelimiter & Left(sColName, Len(sColName) - 1)
' If there is data in the result set...
If Not orsExp.EOF Then
nFields = orsExp.Fields.Count - 1 ' Determine the number of
fields in the result set for later
' Loop through the result set
While Not orsExp.EOF
sOut = "" ' Initialize the output string
' Create a string that contains a delimited value for each field
returned in the recordset.
' Doing this way allows you to pass any recordset to this loop
For x = 0 To nFields
' Here we test to see if this field is one that we want
surrounded by quotes
' For our purposes, we will do this for Text and Dates
If orsExp.Fields(x).Type = 202 Then
sOut = sOut & sQuoteType & orsExp(x) & sQuoteType &
sDelimiter
ElseIf orsExp.Fields(x).Type = 135 Then
sOut = sOut & sQuoteType &
getDateFormated(orsExp(x),sDateFormat) & sQuoteType & sDelimiter
ElseIf orsExp.Fields(x).Type = 6 Then
varTmp = orsExp(x)
If ISNULL(varTmp) Then
varTmp = 0 'Fix for null fields from DTM Update
End If
sOut = sOut & sQuoteType & FormatNumber(varTmp,2) &
sQuoteType & sDelimiter
Else ' No quotes are required...
sOut = sOut & orsExp(x) & sDelimiter
End If
Next
iCount = iCount + 1
' There are more elegant ways to strip the last sDelimiter but...
sOut = iCount & sDelimiter & Left(sOut, Len(sOut) - 1) & vbCrLf
sExport = sExport & sOut
orsExp.MoveNext ' Read in the next record in the
result set
Wend
End If
' Clean up
orsExp.Close
Set orsExp = Nothing
'Set the content type to the specific type that you are sending.
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.ContentType = "text/csv"
Response.ContentType="application/csv"
Response.AddHeader "Content-Disposition", "filename=" &
sExportFileName & ";"
Response.write sHeader & vbCrLf & sExport
End Sub
%>

"JJ" <nospam> wrote in message
news:40**********************@news.dial.pipex.com. ..
Hi,

I have written a web app in asp3 which is used by lots of users.
The data is all held server side.
However, I want it so that the users can export the data in a csv file, much like you can download a statement from online banking.

However, I don't want to save the file to the server, as then anyone else
might guess the filename and download it.
Is there any way to directly generate a file from an asp script. i.e.
instead of asp returning html, it returns csv data which the user can save
away.

Many Thanks in Advance

JJ

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
0
by: Dave Navarro | last post by:
I have used the "Microsoft.XMLHTTP" object to successfully download web pages from other sites. However, I need to download a page from a secure page. Can anyone point me to sample code for...
1
by: Dave | last post by:
Hi Everyone, I was wondering if anyone has ever successfully used SA-FileUp's download feature. I am being forced to change from "ASPSmartUpload" as the server I am moving everything to is...
0
by: Baiju | last post by:
Hello I have an ASP.NET web application which is using some activex controls at the client. We are using internet component donwload technology to download these components. The website was not...
2
by: TJS | last post by:
does ASP.net have a way to secure a delimited text file download ?
6
by: Marc Ris | last post by:
Hi, Following problem, and I can't find any solution for that: I have an aspx page, which will (finally) generate an XLS-File which must (can) be downloaded from the user. After that, the...
4
by: Jeff | last post by:
Our company has to find a way to transfer huge files, target is maximum of 6GB, between sites so we are looking to find the best way to do it. There are lots of criteria we need but the most...
0
by: Claire | last post by:
Digital Download Protection - protect your digital products from theft and link sharing. Products Feature Overview: ° Secure single product sales ° Built-in shopping cart ° Create Membership...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.