By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,383 Members | 2,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,383 IT Pros & Developers. It's quick & easy.

generate CSV or comma delimited

P: n/a
What's the easiest way to generate CSV or a comma delimited file from an ASP
recordset? I've seen a few searching the internet and they appear to be
overkill or out of date.

thanks
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Did you see any that use GetString() ?


"shank" <sh***@tampabay.rr.com> wrote in message
news:um**************@TK2MSFTNGP10.phx.gbl...
What's the easiest way to generate CSV or a comma delimited file from an ASP recordset? I've seen a few searching the internet and they appear to be
overkill or out of date.

thanks

Jul 19 '05 #2

P: n/a
Something like:

Do while not rs.EOF
For each f in rs.fields
sOutput = sOutput & f.value & ","
Next
sOutput = sOutput & vbCrLf
Loop

Then write sOutput to a file using FSO. (If you're not sure about that,
post back.)

Not tested

Ray at work


"shank" <sh***@tampabay.rr.com> wrote in message
news:um**************@TK2MSFTNGP10.phx.gbl...
What's the easiest way to generate CSV or a comma delimited file from an ASP recordset? I've seen a few searching the internet and they appear to be
overkill or out of date.

thanks

Jul 19 '05 #3

P: n/a
Do you happen to have some code example?
Beginning to end...?
The following code appears to be working, but no results.
thanks

"Ray at <%=sLocation%>" <as*@me.forit> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Something like:

Do while not rs.EOF
For each f in rs.fields
sOutput = sOutput & f.value & ","
Next
sOutput = sOutput & vbCrLf
Loop

Then write sOutput to a file using FSO. (If you're not sure about that,
post back.)

Not tested

Ray at work


"shank" <sh***@tampabay.rr.com> wrote in message
news:um**************@TK2MSFTNGP10.phx.gbl...
What's the easiest way to generate CSV or a comma delimited file from an

ASP
recordset? I've seen a few searching the internet and they appear to be
overkill or out of date.

thanks


Jul 19 '05 #4

P: n/a
Hello

Try this:

Set fs=Server.CreateObject("Scripting.FileSystemObject ")
Set ctf = fs.CreateTextFile(Server.MapPath("test.csv"), 2)

If Not rset1.EOF Then
ctf.WriteLine("ISP,Address") '*** If you want titles to your columns
for your csv file

While Not rset1.EOF
ctf.WriteLine(""""&(rset1.Fields("ISP").Value)&""" ,"""&(rset1.Fields("Address").Value)&"""")
rset1.movenext
Wend
End if

ctf.Close
Set fs=nothing

'**************************************
simple loops through your recordset writing out the fields on a line
with commas and creates new line per record, it will also put double
quote around all values, you will need to create a recordset, replace
my recordset tags with yours e.g. (rset1.Fields("ISP").Value), you
will also need to change the titles e.g. ("ISP,Address") to the titles
you want for each column.

CSV File Format should look something like: (using my recordset
fields)

ISP,Address
"ISP Name1","ISP Address1"
"ISP Name2","ISP Address2"

etc.

Hope this helps, I have quickly simplified code hope I haven't made
any mistakes.

"shank" <sh***@tampabay.rr.com> wrote in message news:<Ou**************@TK2MSFTNGP12.phx.gbl>...
Do you happen to have some code example?
Beginning to end...?
The following code appears to be working, but no results.
thanks

"Ray at <%=sLocation%>" <as*@me.forit> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Something like:

Do while not rs.EOF
For each f in rs.fields
sOutput = sOutput & f.value & ","
Next
sOutput = sOutput & vbCrLf
Loop

Then write sOutput to a file using FSO. (If you're not sure about that,
post back.)

Not tested

Ray at work


"shank" <sh***@tampabay.rr.com> wrote in message
news:um**************@TK2MSFTNGP10.phx.gbl...
What's the easiest way to generate CSV or a comma delimited file from an ASP recordset? I've seen a few searching the internet and they appear to be
overkill or out of date.

thanks


Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.