Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unwanted CR in csv output

Status
Not open for further replies.

crjo

Programmer
Jul 3, 2001
15
US
I have a problem with a carriage return at the beginning of each row of data being exported as a .csv file. My code:
<% Response.Buffer=&quot;true&quot; %>
<!--#include file=&quot;../Connections/ConnWilbanks.asp&quot; -->
<%
Dim rsDistList
Dim rsDistList_numRows
Set rsDistList = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsDistList.ActiveConnection = MM_ConnWilbanks_STRING
rsDistList.Source = &quot;SELECT FirstName, LastName FROM tblMembers&quot;
rsDistList.CursorType = 0
rsDistList.CursorLocation = 2
rsDistList.LockType = 1
rsDistList.Open()
rsDistList_numRows = 0
%>
<%
Response.Clear()
Response.AddHeader &quot;Content-Disposition&quot;,&quot;inline; filename=list.csv&quot;
Response.ContentType = &quot;text/csv&quot;
%>
<%
If Not rsDistList.EOF Then
%>
&quot;<%=rsDistList.Fields.Item(&quot;FirstName&quot;).Name%>&quot;,&quot;<%=rsDistList.Fields.Item(&quot;LastName&quot;).Name%>&quot;
<%
Do Until rsDistList.EOF
%>
&quot;<%=rsDistList.Fields.Item(&quot;FirstName&quot;).Value%>&quot;,&quot;<%=rsDistList.Fields.Item(&quot;LastName&quot;).Value%<%=vbCRLF%>
<%
rsDistList.MoveNext
Loop
End If
%>
<%
Response.Flush()
Response.End()
%>
<%
rsDistList.Close()
Set rsDistList = Nothing
%>

The output looks like this:
<row1> [empty]
<row2> [John][Doe]
<row3> [empty]
<row4> [Jane][Doe]
<row5> [empty]
and so on...

Any ideas?
 
So it must be in the FirstName field?
<%=replace(rsDistList.Fields.Item(&quot;FirstName&quot;).Name,vbcrlf,&quot;&quot;)%>
 
I thought of that too. It doesn't matter what field or even what table I use the result is the same.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top