Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   how to store asp code in access and call back as text (http://www.velocityreviews.com/forums/t794742-how-to-store-asp-code-in-access-and-call-back-as-text.html)

Wayne... 06-02-2004 04:03 PM

how to store asp code in access and call back as text
 
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 06-02-2004 04:16 PM

Re: how to store asp code in access and call back as text
 
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>
>
>
>
>




Patrice 06-02-2004 04:17 PM

Re: how to store asp code in access and call back as text
 
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>
>
>
>
>




mustcomment2003@yahoo.com 06-02-2004 05:10 PM

Re: how to store asp code in access and call back as text
 
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>
>
>
>
>




All times are GMT. The time now is 09:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.