Re: retrieve data from database

  •  02-08-2004, 5:41 PM

    Re: retrieve data from database

     

    <%

         Set conn = Server.CreateObject("ADODB.Connection")

        connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("test.mdb")

        conn.Open connstr

      

       ' save the change to the Access Database

       if request("action")="save" then

              MessageField = Request.Form("Editor1_HTMLContent")

              sql="select MessageField from test"

              set rs=server.createobject("adodb.recordset")

              rs.open sql,conn,3,3

              rs.addnew

              rs("MessageField") = MessageField

              rs.update

              response.write "<font size=5 color=darkred>Message added</font>"

              response.write "<br>"

              rs.close

              set rs = nothing

    else

      

               ' Load the data from Database and populate the data to the editor

               MySQL="select top 1 * from test order by id DESC"

               set rs2=conn.execute(MySQL)

               if not rs2.eof then

                    editor.Text = rs2("MessageField")

                    rs2.close

                   set rs2=nothing

               end if

    end if

     

    %>

     

     

    I hope it helps. You can also find the code example in the download package. The file name is todatabase.asp.


    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

View Complete Thread