p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: Displaying Output from Sql Server


Message #1 by m.murray@s... on Tue, 11 Dec 2001 10:16:46
m.murray, here's what I use for a situation like yours.

Sub WriteContentParagraphs(Content)
  Dim nPos
  nPos = Instr(Content, vbCrLf)
  Do While nPos > 0
    Response.Write "<p>" & Left(Content, nPos - 1) & "</p>"
    Content = Mid(Content, nPos + 2)
    nPos = Instr(Content, vbCrLf)
  Loop
  Response.Write "<p>" & Content & "</p>"
End Sub

Some might object to the amount of work being done by the processor, but
this routine serves up pages of articles (40K to 65K of text each) on a
busy site without apparent strain.

If you don't want your text separated as HTML paragraphs (space between
each) you can remove all instances of "<p>" and replace all instances of
"</p>" with "<br>" in the code above.

HTH

----- Original Message -----
From: <m.murray@s...>
To: "Code Clinic" <proasp_codeclinic@p...>
Sent: Tuesday, December 11, 2001 10:16 AM
Subject: [proasp_codeclinic] Displaying Output from Sql Server

 > Is there anyway to preserve the formatting of information in a sql
server
 > database when retreiving it from an asp page?
 >
 > For example in my sql server database i have...
 >
 > Planning Committee - 1992 to 2001
 > Environmental Health Committee - 1994 to 2001
 > Housing Committee - 1994 to 2001
 > Emergency Sub-Committee - 1995 to 2001
 >
 > which is displayed on the page as:
 >
 > Planning Committee - 1992 to 2001 Environmental Health Committee -
1994 to
 > 2001 Housing Committee - 1994 to 2001 Emergency Sub-Committee - 1995
to
 > 2001
 >
 > Is there an easy way to display it as it is? (putting <br> tags in
the
 > database would take ages)



  Return to Index