Unable to Delete Record

Results 1 to 2 of 2

Thread: Unable to Delete Record

  1. #1
    Join Date
    Dec 1969

    Default Unable to Delete Record

    I am using the following code several places in my site to process delete commands. However, when I implement it to delete a record in a table that is based on an AutoNumber field it returns:<BR>ERROR MESSAGE<BR>error &#039 80020009&#039 <BR>Exception occurred.<BR>/Sales/addclient.asp, line 43<BR><BR>Here is the code. Line 43 is the Do Until RecordSet....<BR><BR>CODE<BR>&#039-- Delete Link<BR><BR>If Request.Form("Action") &#060;&#062; "" Then<BR> If Cstr(Request("Action")) &#060;&#062; "" Then<BR><BR> RecordToDelete = Cstr(Request("Action"))<BR><BR> If Not RecordSet.BOF Then<BR> RecordSet.MoveFirst<BR><BR> Do Until RecordSet.Fields("ClientID") = RecordToDelete<BR><BR> RecordSet.MoveNext<BR> <BR> Loop<BR><BR> RecordSet.Delete<BR> RecordSet.Requery<BR> Deleted = "True"<BR> End If<BR> End If<BR>End If<BR>%&#062;<BR><BR>Any ideas on how to make it delete?

  2. #2
    SPG Guest

    Default RE: Unable to Delete Record

    It looks to me like you&#039re comparing a string to an integer (see that cStr(Request("Action"))?<BR><BR>Let&#039s clean that up a bit...<BR><BR>&#039 1 - if we specify where "action" is, ASP won&#039t have<BR>&#039 to search the entire request object...<BR>iRTD = request.Form("action")<BR>&#039 1.5 - Is there something to delete?<BR>if len(iRTD) &#062; 0 then<BR>&#039 2 - if we do just a straight SQL delete, we don&#039t need<BR>&#039 a recordset or a loop! Massive savings!<BR>&#039 Oh, you may not want an open recordset here...<BR>objConn.execute("delete from [" & strTable & "] where clientID = " & cInt(iRTD) & ";")<BR>&#039 3 - you wanted a boolean deletion marker?<BR>bDeleted = true<BR>end if<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