retrieve data from database

Last post 02-08-2004, 5:41 PM by Adam. 1 replies.
Sort Posts: Previous Next
  •  02-05-2004, 1:26 PM 305

    retrieve data from database

    I see an example of how to get data in the database but I do not see an example of how to display the data, for instance "Editor1_HTMLContent".  Does anyone have a code example?

     

    Thanks

     

    Paul

  •  02-08-2004, 5:41 PM 326 in reply to 305

    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 as RSS news feed in XML