How to store the HTML code into database(microsoft access)

Last post 08-11-2008, 10:35 PM by zhihow. 7 replies.
Sort Posts: Previous Next
  •  07-23-2008, 2:42 AM 42460

    How to store the HTML code into database(microsoft access)

    as a topic
    what should i configure the store the HTML code in the cute editor into the database
  •  07-23-2008, 9:47 AM 42472 in reply to 42460

    Re: How to store the HTML code into database(microsoft access)

     
    <!-- #include file = "editeur6/include_CuteEditor.asp" -->
    <%

        if request("action") = "true" then
        
            Set rs_page = Server.CreateObject("ADODB.Recordset")
                rs_page.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/myAccessDB.mdb")
                rs_page.Source = "Select top 1 * from tblPages; "
                rs_page.CursorType = 3
                rs_page.CursorLocation = 2
                rs_page.LockType = 1
                rs_page.Open()
                    
                rs_page.addNew    
                   rs_page("HTML_CONTENT") = request("HTML_CONTENT")    
                rs_page.update    
                
                rs_page.close    
          Set rs_page = nothing     
            
            response.write("<p>Added successfuly into tblPages!</p>")
     
        end if
    %>
      <form name="myform"  method="post">
     
        <%            
      Set editor = New CuteEditor
            editor.ID = "HTML_CONTENT"
            editor.Text = request("HTML_CONTENT")
            editor.FilesPath = "
    editeur6"
            editor.Draw()

        %>
        
       <input type="submit"  class="button" value="Add page" />
       <input type="hidden" name="action" value="true" />
     </form>
    Filed under:
  •  07-23-2008, 11:44 PM 42489 in reply to 42472

    Re: How to store the HTML code into database(microsoft access)

    i apply the coding inside but same cannot store the html code
     
    default.asp
    <!-- #include file = "CuteEditor_Files/include_CuteEditor.asp" -->
    <html>    
        <head>
            <link rel="stylesheet" href="asp.css"  type="text/css" />
        </head>
            <%set conn=Server.CreateObject("ADODB.Connection")
                conn.Provider="Microsoft.Jet.OLEDB.4.0"
                conn.open(server.mappath("database/dbmemo.mdb"))
                set rs = Server.CreateObject("ADODB.Recordset")%>

            <form action="add.asp" method="post" ID="Form1">
                        
            <h1>Enable All Toolbars</h1>
            <hr>
            <p>This example shows you all the predefined buttons. </p>
            <br />
             <%            
      Set editor = New CuteEditor
            editor.ID = "HTML_CONTENT"
            editor.Text = request("HTML_CONTENT")
            editor.FilesPath = "CuteEditor_Files"
            editor.Draw()
        %>
        
             <p>
            
              <input type="submit" name="subsubmit" value="Submit Now">
            </form>
        </body>
    </html>
     
    add.asp
     
    <%set conn=Server.CreateObject("ADODB.Connection")
                conn.Provider="Microsoft.Jet.OLEDB.4.0"
                conn.open(server.mappath("database/dbmemo.mdb"))

    conn.execute("INSERT INTO tblmemo([memo]) values ('" & Request.Form("editor1")& "')")


    Response.Write (Request.Form("HTML_CONTENT"))
    Response.Redirect "default.asp"


    %>
  •  07-24-2008, 4:53 PM 42526 in reply to 42489

    Re: How to store the HTML code into database(microsoft access)

    Never use DYNAMIC SQL to insert text data... NO GOOD, I say NO GOOD, very BAD...

    THIS IS NO GOOD: conn.execute("INSERT INTO tblmemo([memo]) values ('" & Request.Form("editor1")& "')")
     
    Your Request.Form("editor1") value will include invalid caracters like single quotes (') and double quotes (") and will create SQL INSERT Errors. But most important... you could be victim of SQL INJECTION read more here: http://en.wikipedia.org/wiki/SQL_injection 
     
    This is why I've wrote a regular recordset, that way it will work, just take my code and change it to your values...   

    Set rs_page = Server.CreateObject("ADODB.Recordset")
                rs_page.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/dbmemo.mdb")
                rs_page.Source = "Select top 1 * from tblmemo; "
                rs_page.CursorType = 3
                rs_page.CursorLocation = 2
                rs_page.LockType = 1
                rs_page.Open()
                    
                rs_page.addNew    
                   rs_page("memo") = Request.Form("editor1") 
                rs_page.update    
                
                rs_page.close    
          Set rs_page = nothing

    But for your info, this forum is not for ASP tutorials, if you need CLASSIC ASP TUTORIALS, here is some good link;

    http://www.w3schools.com/asp
    http://www.4guysfromrolla.com
    http://www.aspin.com/home/tutorial

    Filed under:
  •  07-25-2008, 2:40 AM 42537 in reply to 42526

    Re: How to store the HTML code into database(microsoft access)

    Thank for help.
    i try to copy your coding to inside but show out the error is below
     
    Error Type:
    ADODB.Recordset (0x800A0CB3)
    Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
    /prototype/CuteEditor2/default.asp, line 14


    Browser Type:
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Avant Browser; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 2.0.50215)

    Page:
    POST 62 bytes to /prototype/CuteEditor2/default.asp

    POST Data:
    HTML_CONTENT=123%0D%0A&HTML_CONTENT%24ClientState=&action=true
     
    Set rs_page = Server.CreateObject("ADODB.Recordset")
                rs_page.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/dbmemo.mdb")
                rs_page.Source = "Select top 1 * from tblmemo; "
                rs_page.CursorType = 3
                rs_page.CursorLocation = 2
                rs_page.LockType = 1
                rs_page.Open()
                    
                rs_page.addNew    <<line 14
                   rs_page("memo") = Request.Form("editor1") 
                rs_page.update    
                
                rs_page.close    
          Set rs_page = nothing
     
     
    Sorry i never learn asp or programing before. just wan install cute editor in my web.

  •  07-25-2008, 12:02 PM 42545 in reply to 42537

    Re: How to store the HTML code into database(microsoft access)

    Oupss... sorry my error...

    Just change
     
    RS_ACTION.LockType = 1
     
      to
     
    RS_ACTION.LockType = 3

     
    Also, be sure to have WRITE access in your folder  "prototype/database"
  •  07-27-2008, 9:12 PM 42567 in reply to 42545

    Re: How to store the HTML code into database(microsoft access)

    Thank for helping.
    i changed it but after i access to my database. not any html coding store in database all just blank in there
  •  08-11-2008, 10:35 PM 42901 in reply to 42545

    Re: How to store the HTML code into database(microsoft access)

    this fixed. but how to display the html coding store in database when i click another button to show the code in browser???
View as RSS news feed in XML