473,508 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Temporary txt,csv Files?

MDW
Hey all

I've got a web-based "database admin console" that uses ADOX, etc. to query a database and return the tables, columns, etc to a form that I can then use to build SQL statements to run against that database. It's very "generic" - i.e., everything is dymanically created but pretty handy to have

If you send it a "SELECT" statement, it can print out a table on the screen showing your recordset. No big deal. What I'd also like to include is some way for users to get that output in a comma- or tab-delimited text file that they can use however they like. There are two ways I know of to accomplish thi

1) Create a big string as I step through the recordset - (strOutput = strOutput & "'" & objRS(I) & "," .....) and then slap strOutput into a <textarea>. This is probably not desirable because the user would have to copy all the content in that <textarea> and manually paste it into Notepad or whatever

2) Use the FSO. However, my limited experience with the FSO leads me to believe that I'd have to SAVE the resultant file before I can send it to users. I don't want to do that.

Does anyone have any suggestions about how else I can accomplish this? Or, if FSO is the way to go (which I suspect it is), bear in mind that my only exposure to FSO is in the context of .vbs files....are there any special tricks you need to use for ASP

TIA

Jul 19 '05 #1
3 1507
Youn can "Response.Write" the file content to the browser (string
concatenation is still not recommended)

Using :
Response.Clear
Response.AddHeader
"Content-disposition","attachment;filename=basenameAAMMJJ.t xt"

Before sending the content will alow to raise the usual download dialog. The
user will be able to save the file on his disk or to open the file (with the
program associated with the txt extension).

Patrice

"MDW" <an*******@discussions.microsoft.com> a écrit dans le message de
news:84**********************************@microsof t.com...
Hey all,

I've got a web-based "database admin console" that uses ADOX, etc. to query a database and return the tables, columns, etc to a form that I can
then use to build SQL statements to run against that database. It's very
"generic" - i.e., everything is dymanically created but pretty handy to
have.
If you send it a "SELECT" statement, it can print out a table on the screen showing your recordset. No big deal. What I'd also like to include is
some way for users to get that output in a comma- or tab-delimited text file
that they can use however they like. There are two ways I know of to
accomplish this
1) Create a big string as I step through the recordset - (strOutput = strOutput & "'" & objRS(I) & "," .....) and then slap strOutput into a
<textarea>. This is probably not desirable because the user would have to
copy all the content in that <textarea> and manually paste it into Notepad
or whatever.
2) Use the FSO. However, my limited experience with the FSO leads me to believe that I'd have to SAVE the resultant file before I can send it to
users. I don't want to do that.
Does anyone have any suggestions about how else I can accomplish this? Or, if FSO is the way to go (which I suspect it is), bear in mind that my only
exposure to FSO is in the context of .vbs files....are there any special
tricks you need to use for ASP?
TIA.

Jul 19 '05 #2
MDW
Excellent!! Thanks so much

FYI, I didn't do concat (and I don't employ it for printing on the screen), I used a loop.

I think I'm gonna reuse this admin page for every site I work on -- it's turning out to be darn useful

Follow-up question, though: On that dialog box, the default file type is *.htm,*.html. Is there any way I can make the default type *.*

Here's the code I use

If Request.Form("Save") <> "" Then ' The user wants to save the recordse

strExt = Request.Form("Save"

Select Case UCase(strExt

Case "TXT

strSep = vbTa

Case "CSV

strSep = ",

End Selec

strFile = "select." & strEx

Response.Clea
Response.AddHeader "Content-disposition","attachment;filename=" & strFil

For row = 0 To lngNumRow

For col = 0 To lngNumCol

thisfld = arrData(col,row

If IsNull(thisfld) The

thisfld = strNul

End I

Response.Write(thisfld

If col < lngNumCols The

Response.Write(strSep

End I

Nex

Response.Write(vbCrLf

Nex

' Manually close the connectio
objConn.Clos
Set objConn = Nothin
Response.En

End I

----- Patrice wrote: ----

Youn can "Response.Write" the file content to the browser (strin
concatenation is still not recommended

Using
Response.Clea
Response.AddHeade
"Content-disposition","attachment;filename=basenameAAMMJJ.t xt

Before sending the content will alow to raise the usual download dialog. Th
user will be able to save the file on his disk or to open the file (with th
program associated with the txt extension)

Patric

"MDW" <an*******@discussions.microsoft.com> a écrit dans le message d
news:84**********************************@microsof t.com..
Hey all
I've got a web-based "database admin console" that uses ADOX, etc. t query a database and return the tables, columns, etc to a form that I ca
then use to build SQL statements to run against that database. It's ver
"generic" - i.e., everything is dymanically created but pretty handy t
have If you send it a "SELECT" statement, it can print out a table on th screen showing your recordset. No big deal. What I'd also like to include i
some way for users to get that output in a comma- or tab-delimited text fil
that they can use however they like. There are two ways I know of t
accomplish thi 1) Create a big string as I step through the recordset - (strOutput strOutput & "'" & objRS(I) & "," .....) and then slap strOutput into
<textarea>. This is probably not desirable because the user would have t
copy all the content in that <textarea> and manually paste it into Notepa
or whatever 2) Use the FSO. However, my limited experience with the FSO leads me t believe that I'd have to SAVE the resultant file before I can send it t
users. I don't want to do that Does anyone have any suggestions about how else I can accomplish this? Or if FSO is the way to go (which I suspect it is), bear in mind that my onl
exposure to FSO is in the context of .vbs files....are there any specia
tricks you need to use for ASP TIA

Jul 19 '05 #3
MDW
Nevermind - I got it figured out. Response.ContentType = "text/plain"
Jul 19 '05 #4

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

Similar topics

1
10195
by: phpninja | last post by:
Greetings, I was wondering if it is possible to delete someone's temporary internet files with javascript? Basically I'm am using a PDF module called HTML_ToPDF. The pdf module takes some output...
5
16761
by: Rosa | last post by:
Hi, I'm trying to clear the TIF on Windows XP programmatically with the below code. This code works fine on any folder but the TIF. For some reason the atEnd() statements always defaults to true...
2
1524
by: Brian O'Haire | last post by:
Any help would be appreciated: I have a routine on an asp.net web page, This code below point to a text box called lbtable. public void GetTables( ) { //string TblDName = new string;...
3
3897
by: Rajiv Das | last post by:
VS 2003, XP SP2 ------------------------------------------------------------ DirectoryInfo temporary = new DirectoryInfo( Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));...
2
3129
by: Kiko + | last post by:
Hi, I've been getting this error: Server Error in '/applicationname' Application. ---------------------------------------------------------------------------- ---- Failed to create...
5
4929
by: localhost | last post by:
I want to determine within my code-behind only the location of the current tem directory for ym ASP.NET files. For example, the latest web app build on my system shows: ...
6
20076
by: Neo The One | last post by:
On my development machine, I often delete all folders/files under C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files. That has not caused me any trouble til now. So now we have...
4
2333
by: Nicolás Castagnet | last post by:
Hi, I write this post because I notice a strange behavior related with "Temporary Internet Files" and maybe some of you can help me to understand it. I am working in a web application with...
5
3833
by: Bas Hendriks | last post by:
Has anyone any idea how asp.net find it's files back after compiling them to the temporary asp.net directory? I found on numerous webpages that the directorynames are chosen random but cannot find...
5
3409
by: rogersw8n | last post by:
Some how, some way the account that creates folders under Temporary Internet files has been changed to a domain account for VS 2003 and VS 2005. I recently installed VS 2005. All seemed to be ok...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.