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

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > June 2004 > how to store asp code in access and call back as text





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

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

2004-06-02, 4:52 pm

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>




Patrice

2004-06-02, 4:52 pm

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..." <wayne@secretwebdesign.com> a écrit dans le message de
news:40bdfa41@212.67.96.135...
> 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>
>
>
>
>



Steven Burn

2004-06-02, 4:52 pm

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..." <wayne@secretwebdesign.com> wrote in message
news:40bdfa41@212.67.96.135...
> 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>
>
>
>
>



mustcomment2003@yahoo.com

2004-06-02, 4:52 pm

On Wed, 2 Jun 2004 17:03:05 +0100, "Wayne..."
<wayne@secretwebdesign.com> wrote:

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>
>
>
>
>


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com