Using already existing database (access)

Last post 11-04-2004, 10:29 PM by Adam. 1 replies.
Sort Posts: Previous Next
  •  11-04-2004, 1:33 PM 2310

    Using already existing database (access)

    I am trying to take an already existing database which is the back-end for a data driven site and add editing functionality using Cute Editor for ASP. I am a recreational ASP coder but understand code pretty well. 

     
    When I pass an ID I get a blank message box and title box.  I want to populate the boxes with already existing data from the database.  At this point, I do not really want to add new records.  That will come later.  I am only interested in the editing aspect of already existing data records.
     
    The two fields I am trying to pass and edit are called "headline" and "copy".  They come from table "tblPageTexts".  Also I have changed the connection string to use a hardlined database location instead of using a mappath...although this is functional because I have been able to add blank records.
     
    Lastly, I believe the problem is in the two variable which are written into the CuteEditor script: TitleField and MessageField.  Can I change these to match my database?  Where are they declared?  Thanks and please excuse my ignorance...
     
    Code is as follows:--------------------------------
     
    <%
      
              dim conn
              dim connstr
              Set conn = Server.CreateObject("ADODB.Connection")
              connstr="Driver={Microsoft Access Driver (*.mdb)};Dbq=W:\Inetpub\dbroot\nls\nlsdata.mdb;Uid=Admin;Pwd=pass;"
              conn.Open connstr
              
              dim content
              
              if request("action")="save" then     <-----Can I remove this section if I am only looking to edit the code and not add new code
               TitleField  = Request.Form("Headline")
               MessageField = Request.Form("Copy")      
               
               sql="select Headline,Copy from tblPageTexts where ID =" & request.QueryString("ID")
               set rs=server.createobject("adodb.recordset")
               rs.open sql,conn,3,3
               
               rs.addnew
               rs("Headline") = TitleField
               rs("Copy") = MessageField
               rs.update
               
               response.write "<font size=5 color=darkred>Message added</font>"
               response.write "<br>"
               rs.close
               set rs = nothing
              else
               MySQL="select top 1 * from tblPageTexts order by id DESC"
               set rs2=conn.execute(MySQL)
               if not rs2.eof then
                TitleField  = rs2("Headline")
                MessageField  = rs2("Copy")
                rs2.close
                set rs2=nothing
               end if
              end if 
             %>
     
     
    Thanks a lot.
     
    Shan
  •  11-04-2004, 10:29 PM 2315 in reply to 2310

    Re: Using already existing database (access)

    Shan,
     
    TitleField and MessageField are two variables to hold the data. You can change as you wish.
     

    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