Updating database pages (and not adding a new record)

Last post 10-20-2004, 2:19 AM by bnmiros. 4 replies.
Sort Posts: Previous Next
  •  10-19-2004, 11:39 AM 2138

    Updating database pages (and not adding a new record)

     

    URGENT:

     
    I've spent a good part of my weekend trying to implement a code that will upload information from your CuteEditor to the database.
     
    I've created a separate HTML page, that has a link that passes an ID value to my todatabase.asp page (example - todatabase.asp?ID=3)
     
    Right now there is a code that goes throuugh the records and creates a new one at the end of the list:
     
               rs.addnew
               rs("TitleField") = TitleField
               rs("MessageField") = MessageField
               rs.update
     
    I need that to be updating the row that I passed an ID for, and not create a new record.
     
    Finally what is the easiest way to display a single page (a row) without giving anyone permissions to change them (to display that page).I would like to use ID pass, just a s above.
     
    Please help me ASAP!
     
    Thank you
  •  10-19-2004, 2:30 PM 2140 in reply to 2138

    Re: Updating database pages (and not adding a new record)

    bnmiros,

     
    Here is the Code:
     
    ID = Request("ID")

    If ID <> "" then

        sql="select TitleField,MessageField from test where id="&CInt(ID)&""
        set rs=server.createobject("adodb.recordset")

        rs.open sql,conn,3,3
               
        rs("TitleField") = TitleField
        rs("MessageField") = MessageField
        rs.update
        rs.Close

        Set rs = nothing

    End If
     
    Here are a few good ASP sites:

    Best regards


    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

  •  10-19-2004, 3:42 PM 2143 in reply to 2140

    Re: Updating database pages (and not adding a new record)

            I've replaced this code with the code you provided. I also made a page that passes an ID to it:   <a href="page.asp?ID=2">link</a>

    But it still doesn't work. What am I doing wrong??
     
     
      if request("action")="save" then
               TitleField  = Request.Form("TitleField")
               MessageField = Request.Form("Editor1_HTMLContent")      
               
               sql="select TitleField,MessageField from test"
               set rs=server.createobject("adodb.recordset")
               rs.open sql,conn,3,3
               
               rs.addnew
               rs("TitleField") = TitleField
               rs("MessageField") = MessageField
               rs.update
               
               response.write "<font size=5 color=red>Kari, your message has been added</font>"
               response.write "<br>"
               rs.close
               set rs = nothing
              else
               MySQL="select top 1 * from test order by id DESC"
               set rs2=conn.execute(MySQL)
               if not rs2.eof then
                TitleField  = rs2("TitleField")
                MessageField  = rs2("MessageField")
                rs2.close
                set rs2=nothing
               end if
              end if 
  •  10-19-2004, 5:32 PM 2146 in reply to 2143

    Re: Updating database pages (and not adding a new record)

    Your Sql statement need to only return one record.  sql="select TitleField,MessageField from test"
    needs to be sql="select TitleField,MessageField from test where id=" & Request.Querystring("ID")
  •  10-20-2004, 2:19 AM 2150 in reply to 2146

    Re: Updating database pages (and not adding a new record)

    I am so disapointed that I can't get this to work. I've tried it everywhich way.

     
    It keeps on doing the same, and when  I replace it with the line you said I should, it gives me an error:

    Microsoft JET Database Engine error '80040e14'

    Syntax error (missing operator) in query expression 'id='.

    /text_edit/todatabase.asp, line 47

     
    Not everyone wants to have a FORUM like application.
    The true power of this app should be the ability to update the already created web pages.  I think this would really be beneficial for all.
     
    Please, if you could, could you email the complete code from your submissions to [email protected].  I would really like to be able to do what you are saying is posible with updating existing pages. I've tried emailing you, but it wouldn't let me submit it over the forum.
    I would really appreciate it.
     
    Thank you Adam
View as RSS news feed in XML