Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored proc new line(\n) prob in ASP

Author  Topic 

refreeman4
Starting Member

6 Posts

Posted - 2002-04-12 : 12:34:17
I am throwing the results of the following statement into a textarea field in an ASP page:
SELECT claimLogStatusText + '\n - ' + CONVERT(char(10), claimLogCreated, 101) + '\n\n' AS Logentry FROM ClaimLog WHERE claimID ="+claimID+" ORDER BY claimLogID
and get the following
Event Log Date
- 05/24/2001

But if I put the same statement into a stored proc and fill my textarea with the results I end up with the new line chars as part of the string rather than control chars like the following
Event Log Date\n - 05/24/2001\n\nClaim Start Date\n - 05/24/2001

Output from Query Analyzer looks the same and Javascript\html is the same (just supplying my proc to the Execute statement instead of a SQL string). Makes me think the proc is returning the data(\n) in a different manner that I just can't see
Any ideas?

refreeman4
Starting Member

6 Posts

Posted - 2002-04-12 : 15:09:32
I noticed several reads but no replies so I thought I would post my ASP code... I still can't finger it out
The only thing I am changing in the ASP page is which sql var I am commenting out.

<%@ language="JavaScript1.3"%>
<%
var sql="SELECT claimLogStatusText + '\n - ' + CONVERT(char(10), claimLogCreated, 101) + '\n\n' AS LogEntry FROM ClaimLog WHERE claimID ="+claimID+" ORDER BY claimLogID";
//var sql="dbo.spRSClaimLog "+claimID;
var wordDateLog='';
var RS=Conn.Execute(sql);
for(;!RS.EOF;RS.MoveNext()){
wordDateLog+=String(RS('LogEntry'));
}
%>
<html><head></head><body>
<textarea rows="30" name="claimDateLog" cols="20" style="width:95%;height:170" readonly><%=wordDateLog%></textarea>
</body></html>

Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-04-12 : 15:46:07
SQL Server doesn't know what a \n is. If the \n gets to SQL Server intact it just thinks it's a \n. For example

select '5\n4'
select '5' + char(13) + '4'


The first select returns 5\n4 while the select example returns

5
4


I think you'll need to do somethign different with Java to have it convert \n to the actual ASCII value of a carriage return. Does that help? Sorry I don't know Java :(

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
   

- Advertisement -