Re: Help with updating SQL database entries with CuteEditor

  •  11-27-2004, 2:13 AM

    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
    %>
View Complete Thread