469,343 Members | 5,380 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

generate CSV or comma delimited

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
4 16375
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
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
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
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.

Similar topics

3 posts views Thread by Elmo Watson | last post: by
1 post views Thread by John B. Lorenz | last post: by
9 posts views Thread by Wayne | last post: by
9 posts views Thread by Bernie Yaeger | last post: by
4 posts views Thread by JustSomeGuy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.