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

Discussion in 'ASP General' started by Wayne..., Jun 2, 2004.

  1. Wayne...

    Wayne... Guest

    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>
    Wayne..., Jun 2, 2004
    #1
    1. Advertising

  2. Wayne...

    Steven Burn Guest

    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..." <> 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>
    >
    >
    >
    >
    Steven Burn, Jun 2, 2004
    #2
    1. Advertising

  3. Wayne...

    Patrice Guest

    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..." <> 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>
    >
    >
    >
    >
    Patrice, Jun 2, 2004
    #3
  4. Wayne...

    Guest

    On Wed, 2 Jun 2004 17:03:05 +0100, "Wayne..."
    <> 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>
    >
    >
    >
    >
    , Jun 2, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nick
    Replies:
    3
    Views:
    3,182
    Eliyahu Goldin
    Dec 15, 2004
  2. =?Utf-8?B?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    634
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  3. sandhu
    Replies:
    1
    Views:
    765
    Alvin Bruney [MVP]
    May 17, 2007
  4. c676228
    Replies:
    10
    Views:
    217
    c676228
    Oct 19, 2006
  5. Replies:
    4
    Views:
    390
    Bob Barrows
    Apr 6, 2009
Loading...

Share This Page