update statement troubles

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • csdowney
    New Member
    • Oct 2006
    • 1

    #1

    update statement troubles

    here is my trouble - i have 3 pages, the first runs a simple querey and populates a drop down list, the user picks one of the returns and upon submission is sent to the second page - there the user can modify certin fields, once they click on submitting changes the third page takes the modified data, strips out single quotes and updates the table and displays the information that was supposedly written to the table. here is the code on the third page

    Dim Comments

    Comments = Request.Form("N ewComments")

    Dim cnnSimple
    Dim rstSimple
    Dim strDBPath

    Comments = Replace(Comment s, "'", "")

    strDBPath = Server.MapPath( "ProjectsReport .mdb")

    Set cnnSimple = Server.CreateOb ject("ADODB.Con nection")

    cnnSimple.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & strDBPath & ";"

    Set rstSimple = cnnSimple.Execu te("UPDATE tblProjects SET Comments = '" & Comments & "' WHERE Project = '" & ProjectName & "'")


    Now here is the trouble, the values are passed ok, displayed ok, querey appears to work however the table is not updated - any suggestions.
  • albertw
    Contributor
    • Oct 2006
    • 267

    #2
    Originally posted by csdowney
    here is my trouble - i have 3 pages, the first runs a simple querey and populates a drop down list, the user picks one of the returns and upon submission is sent to the second page - there the user can modify certin fields, once they click on submitting changes the third page takes the modified data, strips out single quotes and updates the table and displays the information that was supposedly written to the table. here is the code on the third page

    Dim Comments

    Comments = Request.Form("N ewComments")

    Dim cnnSimple
    Dim rstSimple
    Dim strDBPath

    Comments = Replace(Comment s, "'", "")

    strDBPath = Server.MapPath( "ProjectsReport .mdb")

    Set cnnSimple = Server.CreateOb ject("ADODB.Con nection")

    cnnSimple.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & strDBPath & ";"

    Set rstSimple = cnnSimple.Execu te("UPDATE tblProjects SET Comments = '" & Comments & "' WHERE Project = '" & ProjectName & "'")


    Now here is the trouble, the values are passed ok, displayed ok, querey appears to work however the table is not updated - any suggestions.
    hi

    can't you use

    With datReport.Recor dset
    .Edit
    'make changes code
    .Update
    End With

    datReport.Refre sh

    where datReport is the dataconnection to ProjectReport.m db
    ???

    Comment

    • scripto
      New Member
      • Oct 2006
      • 143

      #3
      Originally posted by csdowney
      here is my trouble - i have 3 pages, the first runs a simple querey and populates a drop down list, the user picks one of the returns and upon submission is sent to the second page - there the user can modify certin fields, once they click on submitting changes the third page takes the modified data, strips out single quotes and updates the table and displays the information that was supposedly written to the table. here is the code on the third page

      Dim Comments

      Comments = Request.Form("N ewComments")

      Dim cnnSimple
      Dim rstSimple
      Dim strDBPath

      Comments = Replace(Comment s, "'", "")

      strDBPath = Server.MapPath( "ProjectsReport .mdb")

      Set cnnSimple = Server.CreateOb ject("ADODB.Con nection")

      cnnSimple.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & strDBPath & ";"

      Set rstSimple = cnnSimple.Execu te("UPDATE tblProjects SET Comments = '" & Comments & "' WHERE Project = '" & ProjectName & "'")


      Now here is the trouble, the values are passed ok, displayed ok, querey appears to work however the table is not updated - any suggestions.

      As per your code, ProjectName seems to be blank??
      and why are you using a recordset? this is an update statment - try just executing the command

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        Originally posted by scripto
        As per your code, ProjectName seems to be blank??
        and why are you using a recordset? this is an update statment - try just executing the command
        Also you don't need to check the database to see if the update worked. Put a Long variable after your SQL statement and check it for the number of rows affected by your code:
        Code:
        cnnSimple.Execute("UPDATE tblProjects SET Comments = '" & Comments & "' WHERE Project = '" & ProjectName & "'", [B]lngRowsAffected[/B])
        
        If [B]lngRowsAffected[/B] = 0 Then
           MsgBox "Oh Dear! Something amiss with my SQL programming again"
        End If
        :)

        Comment

        Working...