Help with updating SQL database entries with CuteEditor

Last post 11-29-2004, 6:53 PM by Michael Mullis. 6 replies.
Sort Posts: Previous Next
  •  11-27-2004, 12:00 AM 2635

    Help with updating SQL database entries with CuteEditor

    Hello.  I'm in need of a little code assistance since I am not used to this program quite yet.
     
    Currently, we use a straight <textarea> box to input our stuff into a dynamic ASP website.  More recently we were using a free program htmlarea to do our WYSIWYG editing.  It's ok, but not stable, so I purchased CuteEditor for ASP.
     
    What I need to do is replace the <textarea> with this, but there is a catch.  The text body is then saved into MS SQL.  Here is the current line:
     
    "<textarea id="prebody" name="prebody" cols="100" rows="40"><% = strBody %></textarea>"
     
    The id and name coincide with the name of the SQL field that gets saved, and the <% = strbody %> is the text body that would be put into the editor already if there was any..  The SQL field is called earlier in the ASP script.

    Now I figured out that putting strbody into the content = field it will come up either blank, or if there's actual content in that database entry, it will appear.  But when I click submit, I want the editor to put it's contents into the database under the prebody entry.

    Does this make sense?  Let me know what other info you need.
     
     
    Thanks
    Mike Mullis
    Next Level Gaming
  •  11-27-2004, 2:13 AM 2636 in reply to 2635

    Re: Help with updating SQL database entries with CuteEditor

    By the way, here is where I am stuck on one of my scripts:

    This is the script where the editor kicks in.  I have truncated out the unrelated stuff:

    <!-- #include virtual="/managers/editor/include_cuteeditor.asp" --> 

    >>  Here is where I open up what is already in rs("prebody") in case it is an existing entry  <<

    <%
    strAction = Request("action")
    If strAction = "edit" or strAction = "delete" Then
     strcontrol = Request("control")
     
     set rs = Server.CreateObject("ADODB.Recordset")
     rs.ActiveConnection = dbvar
     rs.Source = "SELECT * FROM PREVIEWS WHERE (preID = '" & strcontrol & "')"
     rs.CursorType = 3
     rs.CursorLocation = 2
     rs.LockType = 3
     rs.Open() 

      strBody  = rs("preBody")

    >>  This is the start of the form <<
      
    <form action="prevsDBAction.asp" method="post" name="frmMain">
    <input type="hidden" name="action" value="<% = strAction %>">
    <input type="hidden" name="control" value="<% = strControl %>">
    <input type="hidden" name="sitepass" value="<% = Session("sitepass") %>"> 

    >>  Here is where CuteEditor is called.  If I am editing a current entry, then "strbody" will populate the editor already.  If not, it will be blank <<

                <td colspan="2" width="100%" valign="top"> <b><font face="Verdana, Arial, Helvetica" size="2">Preview
                  Body:  <a href="http://www.nlgaming.com/forums/topic.asp?TOPIC_ID=520" target=_blank>Click Here for Help with inserting pictures, movies, quotes, and other HTML tricks!</a><br>
        <%
              dim content
                   
              content = strbody
                 
              Dim editor
              set editor = New CuteEditor
         
              editor.ID = "prebody"
              editor.Text = content
              editor.FilesPath = "/managers/editor/CuteEditor_Files"
              editor.ImageGalleryPath = "/games"
              editor.MaxImageSize = 50
              editor.AutoConfigure = "enableall"
              'editor.Template= "Bold,Italic,Underline"
              'editor.StyleSheetPath = "/grey2.css"
              'editor.Width = 740
              'editor.Height = 240
              editor.Draw() 
         %>
              </tr>
              <tr>
                <td colspan="7" height="50" align="center" valign="top">
                  <input type="submit" name="submit" value="Submit"> 
    >>Eventual end of the form, and posting to the next script below <<    

    </form>

    And this is the code that actually updates into the SQL database.  This is th "prevsDBaction.asp" that is called from the form.  The part that I need to update is the rs("prebody") tag.  Right now it calls a request from what used to be the textarea id=prebody.  Now I have to figure out how to save the editor data into that rs call. 

    I am NOT above rewriting this next code if I have to.  But I am just totally stuck.
     

    <!-- #include virtual="/managers/editor/include_cuteeditor.asp" -->
    <!-- #INCLUDE VIRTUAL="/includes/nohealth.asp" -->
    <%
    redirPage = "prevsDB.asp"
    strAction = Request("action")
    dbTableName = "previews"


    Function LongTextToHTML(LongText)

        dim sAns
     sAns= replace(LongText, "  ", "  ")
     sAns = replace(sAns, vbcrlf, "<BR>")

     sAns  = replace(sAns, "<" & chr(37), "")
       sAns  = replace(sAns, chr(37)  & ">", "")

     LongTextToHTML = sAns

    End Function

    >>  This is a central updating area subroutine <<
    Sub updateRecord(rs) 
      
     rs("prebody")  = request("prebody")   (Also tried rs("prebody") = request.form("prebody_HTMLContent"))
     rs.Update
     
     rs.close
     set rs=nothing
     set cmdTemp=nothing
    End Sub

    >> Re - opening SQL database for preperation of prebody update <<

    set rs = Server.CreateObject("ADODB.Recordset")
    rs.ActiveConnection = dbvar
    rs.CursorType = 3
    rs.CursorLocation = 2
    rs.LockType = 3


    >> If I am adding a new entry <<

    Select Case strAction
    Case "add"
     
     rs.Source = "SELECT * FROM " & dbTableName
     rs.Open()
     
     rs.addnew
     Call updateRecord(rs)  >>The Subroutine that updates rs("prebody")
      
     set rs2 = Server.CreateObject("ADODB.Recordset")
     rs2.ActiveConnection = dbvar
     rs2.CursorType = 3
     rs2.CursorLocation = 2
     rs2.LockType = 3
     rs2.source = "SELECT * FROM " & dbTableName
     rs2.Open()
     rs2.movelast
     
     strcontrol = rs2("preID")
     rs2.close()
     
     Call updatePlatforms(rs)
     response.redirect(redirPage)


    >>And if I am editing a current entry <<

    CASE "edit"
     strControl = Request("control")
     rs.Source = "SELECT * FROM " & dbTableName & " WHERE (preID = " & strcontrol & ")"
     rs.Open()
     Call updateRecord(rs)
     Call updatePlatforms(rs)
     response.redirect(redirPage)


    END SELECT
    %>
  •  11-29-2004, 5:51 PM 2682 in reply to 2636

    Re: Help with updating SQL database entries with CuteEditor

    Wow, this is long file.

    Try replace:

    rs("prebody")  = request("prebody")
     
    with
     
    rs("prebody")  = Request.Form("prebody_HTMLContent")

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  11-29-2004, 6:04 PM 2685 in reply to 2682

    Re: Help with updating SQL database entries with CuteEditor

    Sorry.  I should have truncated the code.  In fact I will try and do that after posting this.
     
    I did try that before posting all this.  It does not seem to grab the form info from the editor.   I also tried in various places this:
     
    prebody = request.form("prebody_HTMLContent")
     
    and then
     
    rs("prebody") = prebody.
     
    Somehow it just looks like the Request.Form command isn't grabbing the content from inside.  Now, I'm pretty certain of this, but Request.Form is not case sensitive correct?
  •  11-29-2004, 6:13 PM 2686 in reply to 2685

    Re: Help with updating SQL database entries with CuteEditor

    Ok, I can also cut out all the extra stuff from the code and are just concentrating on what I need to add the CuteEditor content to the SQL 2003 Database.
  •  11-29-2004, 6:23 PM 2687 in reply to 2686

    Re: Help with updating SQL database entries with CuteEditor

    Michael Mullis,

    Here is a simple example:

     
    If you are not using the built-in save button, make sure you put onfocus event on the your submit button.
  •  11-29-2004, 6:53 PM 2692 in reply to 2687

    Re: Help with updating SQL database entries with CuteEditor

    "If you are not using the built-in save button, make sure you put onfocus event on the your submit button."
    That was it right there!  once i put the onfocus in the submit button, it kicked right in. 
     
    Thanks!  I swear I was up for hours trying to figure this one out.  :)
View as RSS news feed in XML