how to store asp code in access and call back as text

W

Wayne...

I'm trying to make a sort of source code libary for some customers of
commonly used code to save them a bit of time [and cut down on my tech
support]
the problem I have is that although I can get the asp [and php etc...] code
into a field of an access database it will not be called back as text....
an example of what I am using is below...
all I am after is basically what lots of other major source code sites do
and that is diplay the code as text so the user can cut and paste it into
their projects.
this has got me beat.... I wasn't sure wether I needed to encode the source
somehow before putting into access or not [some of the html based stuff
trys to render itself on the page!]
Sorry for the untidy code BTW.
lots of thanks in advance if anyone can point me in the right direction
about this....

Wayne...

PS the field's code, code2 and code3 are the actual code fields
CODE:
============
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsCodevault 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("codevault.mdb")
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM asp;"
rsCodevault.Open strSQL, adoCon
%>

<HTML>

<HEAD>
<TITLE>Codevault </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
</HEAD>
<BODY BGCOLOR = "#FFFFFF">
<CENTER><H2>ASP Code</H2></CENTER>

<% if sCaption <> "" then
response.write "<B><FONT COLOR = RED>" & sCaption & "</B></FONT><P>"
end if
%>


<b>Title: </b>
<% Response.write (rsCodevault("title"))%>
<br>
<b>Posted by: </b>
<%
Response.write (rsCodevault("author")) 'displays ok
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 1</b>")
Response.write ("<br>")
TempString = rsCodevault("code") 'doesn't work
Response.write ("</p>")
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 2</b>")
Response.write ("<br>")
Response.write (rsCodevault("code2")) 'doesn't work
Response.write ("</p>")
Response.write ("<p>")
Response.write ("<b>Code 3</b>")
Response.write ("<br>")
Response.write (rsCodevault("code3")) 'doesn't work
Response.write ("</p>")
Response.write ("<b>About</b>")
Response.write ("<br>")
Response.write (rsCodevault("explaination")) 'works
Response.write ("<br>")
%>
<%
rsCodevault.Close
Set rsCodevault = Nothing
Set adoCon = Nothing
%>
</body>
</html>
 
S

Steven Burn

sSource = Replace(rst("Source"), "<", "&lt;")
sSource = Replace(rst("Source"), ">", "&gt;")

or

sSource = Replace(Replace(rst("Source"), "<", "&lt;"), ">", "&gt;")

_Should_ work.........

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


Wayne... said:
I'm trying to make a sort of source code libary for some customers of
commonly used code to save them a bit of time [and cut down on my tech
support]
the problem I have is that although I can get the asp [and php etc...] code
into a field of an access database it will not be called back as text....
an example of what I am using is below...
all I am after is basically what lots of other major source code sites do
and that is diplay the code as text so the user can cut and paste it into
their projects.
this has got me beat.... I wasn't sure wether I needed to encode the source
somehow before putting into access or not [some of the html based stuff
trys to render itself on the page!]
Sorry for the untidy code BTW.
lots of thanks in advance if anyone can point me in the right direction
about this....

Wayne...

PS the field's code, code2 and code3 are the actual code fields
CODE:
============
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsCodevault 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("codevault.mdb")
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM asp;"
rsCodevault.Open strSQL, adoCon
%>

<HTML>

<HEAD>
<TITLE>Codevault </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
</HEAD>
<BODY BGCOLOR = "#FFFFFF">
<CENTER><H2>ASP Code</H2></CENTER>

<% if sCaption <> "" then
response.write "<B><FONT COLOR = RED>" & sCaption & "</B></FONT><P>"
end if
%>


<b>Title: </b>
<% Response.write (rsCodevault("title"))%>
<br>
<b>Posted by: </b>
<%
Response.write (rsCodevault("author")) 'displays ok
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 1</b>")
Response.write ("<br>")
TempString = rsCodevault("code") 'doesn't work
Response.write ("</p>")
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 2</b>")
Response.write ("<br>")
Response.write (rsCodevault("code2")) 'doesn't work
Response.write ("</p>")
Response.write ("<p>")
Response.write ("<b>Code 3</b>")
Response.write ("<br>")
Response.write (rsCodevault("code3")) 'doesn't work
Response.write ("</p>")
Response.write ("<b>About</b>")
Response.write ("<br>")
Response.write (rsCodevault("explaination")) 'works
Response.write ("<br>")
%>
<%
rsCodevault.Close
Set rsCodevault = Nothing
Set adoCon = Nothing
%>
</body>
</html>
 
P

Patrice

Try to enclose the code within a PRE tag.

You could also display the code and have a separate link to copy/paste or
download the code (it would allow to use HTML let's sya to have comments in
green or somethuing similar).

Patrice

Wayne... said:
I'm trying to make a sort of source code libary for some customers of
commonly used code to save them a bit of time [and cut down on my tech
support]
the problem I have is that although I can get the asp [and php etc...] code
into a field of an access database it will not be called back as text....
an example of what I am using is below...
all I am after is basically what lots of other major source code sites do
and that is diplay the code as text so the user can cut and paste it into
their projects.
this has got me beat.... I wasn't sure wether I needed to encode the source
somehow before putting into access or not [some of the html based stuff
trys to render itself on the page!]
Sorry for the untidy code BTW.
lots of thanks in advance if anyone can point me in the right direction
about this....

Wayne...

PS the field's code, code2 and code3 are the actual code fields
CODE:
============
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsCodevault 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("codevault.mdb")
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM asp;"
rsCodevault.Open strSQL, adoCon
%>

<HTML>

<HEAD>
<TITLE>Codevault </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
</HEAD>
<BODY BGCOLOR = "#FFFFFF">
<CENTER><H2>ASP Code</H2></CENTER>

<% if sCaption <> "" then
response.write "<B><FONT COLOR = RED>" & sCaption & "</B></FONT><P>"
end if
%>


<b>Title: </b>
<% Response.write (rsCodevault("title"))%>
<br>
<b>Posted by: </b>
<%
Response.write (rsCodevault("author")) 'displays ok
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 1</b>")
Response.write ("<br>")
TempString = rsCodevault("code") 'doesn't work
Response.write ("</p>")
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 2</b>")
Response.write ("<br>")
Response.write (rsCodevault("code2")) 'doesn't work
Response.write ("</p>")
Response.write ("<p>")
Response.write ("<b>Code 3</b>")
Response.write ("<br>")
Response.write (rsCodevault("code3")) 'doesn't work
Response.write ("</p>")
Response.write ("<b>About</b>")
Response.write ("<br>")
Response.write (rsCodevault("explaination")) 'works
Response.write ("<br>")
%>
<%
rsCodevault.Close
Set rsCodevault = Nothing
Set adoCon = Nothing
%>
</body>
</html>
 
M

mustcomment2003

On Wed, 2 Jun 2004 17:03:05 +0100, "Wayne..."

try "server.htmlencode()" ... I just lightly skimmed the article but
it seems you want to put the text to the browser... try that
function.

I'm trying to make a sort of source code libary for some customers of
commonly used code to save them a bit of time [and cut down on my tech
support]
the problem I have is that although I can get the asp [and php etc...] code
into a field of an access database it will not be called back as text....
an example of what I am using is below...
all I am after is basically what lots of other major source code sites do
and that is diplay the code as text so the user can cut and paste it into
their projects.
this has got me beat.... I wasn't sure wether I needed to encode the source
somehow before putting into access or not [some of the html based stuff
trys to render itself on the page!]
Sorry for the untidy code BTW.
lots of thanks in advance if anyone can point me in the right direction
about this....

Wayne...

PS the field's code, code2 and code3 are the actual code fields
CODE:
============
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsCodevault 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("codevault.mdb")
Set rsCodevault = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM asp;"
rsCodevault.Open strSQL, adoCon
%>

<HTML>

<HEAD>
<TITLE>Codevault </TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
</HEAD>
<BODY BGCOLOR = "#FFFFFF">
<CENTER><H2>ASP Code</H2></CENTER>

<% if sCaption <> "" then
response.write "<B><FONT COLOR = RED>" & sCaption & "</B></FONT><P>"
end if
%>


<b>Title: </b>
<% Response.write (rsCodevault("title"))%>
<br>
<b>Posted by: </b>
<%
Response.write (rsCodevault("author")) 'displays ok
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 1</b>")
Response.write ("<br>")
TempString = rsCodevault("code") 'doesn't work
Response.write ("</p>")
Response.write ("<br>")
Response.write ("<p>")
Response.write ("<b>Code 2</b>")
Response.write ("<br>")
Response.write (rsCodevault("code2")) 'doesn't work
Response.write ("</p>")
Response.write ("<p>")
Response.write ("<b>Code 3</b>")
Response.write ("<br>")
Response.write (rsCodevault("code3")) 'doesn't work
Response.write ("</p>")
Response.write ("<b>About</b>")
Response.write ("<br>")
Response.write (rsCodevault("explaination")) 'works
Response.write ("<br>")
%>
<%
rsCodevault.Close
Set rsCodevault = Nothing
Set adoCon = Nothing
%>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top