Update/Delete record is the wrong one

Results 1 to 3 of 3

Thread: Update/Delete record is the wrong one

  1. #1
    Techwun Guest

    Default Update/Delete record is the wrong one

    I have a user info mdb that&#039s used by a series of ASP pages.<BR>One to view the db info which hyperlinks to the second page via Querystring method(rs("ID")). The second page displays all user info and has two buttons: update & delete. When I update the info the record that always ends up being the one updated is the first in the table. It becomes a duplicate of whichever one I passed via querystring. Also happens when deleting records.<BR><BR>Why is that? I also duplicated the CDO mailing list app from www.4guysfromrolla.com and it also deletes the wrong one. Could it be my server? I&#039m using IIS 4.0 w/ fpse2k, NTsp5, and MDAC2.5.

  2. #2
    Join Date
    Dec 1969

    Default RE: Update/Delete record is the wrong one

    it&#039s not your server - you&#039re probably having trouble with passing the record ID to the update/delete page. try Response.writing out your SQL strings without executing them to see if you can spot the problem that way<BR><BR>j

  3. #3
    Techwun Guest

    Default RE: Update/Delete record is the wrong one

    I&#039ve done that and it doesn&#039t seem to help any. The variables are all right. I&#039ve used session objects and the querystring method.<BR>The variables are correct until the update or delete occurs.<BR> Here&#039s the code:<BR><BR>Dim rs, Updated, Mchoice, strSql<BR>Mchoice = Session("EditMmbr")<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR>&#039str Sql = "Select * From whs Where ID = &#039" & Mchoice & "&#039"<BR>Response.Buffer = True<BR>response.write(Mchoice)<BR>rs.Open "whs", cn, , adLockPessimistic, adCmdTable<BR>&#039cn.Execute(strSql)<BR><BR>If Request.Form("btnUpdate") = "Update" Then<BR><BR> &#039-- Add records to database from form --<BR><BR>rs.Fields("Name") = Request.Form("Name")<BR>rs.Fields("Email") = Request.Form("Email")<BR>rs.Fields("Phone") = Request.Form("Phone")<BR>rs.Fields("State") = Request.Form("State")<BR>rs.Fields("Location") = Request.Form("Location")<BR>rs.Update<BR>Updated = "True"<BR><BR>End If<BR><BR><BR><BR>If Updated = "True" Then<BR> Response.Write("&#060;font size=4&#062;&#060;b&#062;&#060;font color=" & Chr(34) & "red" & Chr(34) & "&#062;" & rs.Fields("Name") & "&#060;/font&#062; has been updated&#060;/b&#062;&#060;/font&#062;&#060;p&#062;")<BR>End If<BR><BR><BR><BR>If Request.Form("btnDelete") = "Delete" Then<BR> rs.Delete adAffectCurrent<BR> rs.Requery<BR>End If<BR><BR><BR>The variable in the If Updated = True statement also fills correctly. The problem is the database data. What gives??<BR><BR>

Posting Permissions

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