totally confused on updating databases

Results 1 to 3 of 3

Thread: totally confused on updating databases

  1. #1
    adam stokes Guest

    Default totally confused on updating databases

    i&#039ve tried and tried and tried. here is my problem, hopefully i can explain this.<BR><BR>Things that i have.<BR>OK, i have a database with records ..<BR>I have a form for viewing records it has a title box and a article box.<BR>On that form i have button&#039s that do two things either UPDATE the article being shown or DELETE the article being shown.<BR><BR>Here is the code.<BR>id = Request("view")<BR>If id = "" Then id = 1<BR>If Not IsNumeric(id) Then id = 1<BR><BR>Dim objConn<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & _<BR> "dbq=" & Server.MapPath("Article.mdb")<BR>objConn.Open<BR>< BR>dim objRS<BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR>set rs = objconn.execute("select * from article where(id=" & id & ")")<BR><BR>objRS.Open rs, objConn<BR>If request.form("btnUpdate")= "update" Then<BR> objRS("title") = Request.Form("title")<BR> objRS("article") = Request.Form("article")<BR> objRS.Update<BR> <BR>End If<BR><BR>If request.form("btnDelete")= "delete" then<BR><BR> objRS.Delete<BR>End If<BR><BR><BR>%&#062; <BR><BR>Now before i changed my coding i was doing a string comparison on the TITLE box of the form to search through the database giving it the ability to delete or update the records as long as the title didn&#039t change from when it was created.<BR><BR>Good so far? hope so.<BR><BR>Now my dilemma is i want to be able to change my title and change my articles if i have a spelling mistake, etc. ...<BR><BR>But if the title changes then my search script will not find it in the recordset therefore i get an error saying it cannot update.<BR><BR>MY QUESTION IS: How do i delete/update records by having my program Search for the AutoID that is attached by MS Access and then do the functions specified (updating and deleting)<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: totally confused on updating databases

    Yes.<BR>You&#039ve got to do an edit first.<BR>e.g.:<BR>objRS.Edit<BR>objRS("title") = Request.Form("title")<BR>objRS("article") = Request.Form("article")<BR>objRS.Update

  3. #3
    Join Date
    Dec 1969

    Default RE: totally confused on updating databases

    &nbsp;<BR>I tried that method with update syntax will not be supported in ASP SQL.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts