Using already existing database (access)

  •  11-04-2004, 1:33 PM

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