Error when updating record

Results 1 to 2 of 2

Thread: Error when updating record

  1. #1
    Join Date
    Dec 1969

    Default Error when updating record

    I am a new ASP programmer so bear with me. On the previous page&#039;s form, the user checks the events they wish to attend. I then add records to the registration table based on the events. This is working fine. Each checkbox on the form is given a value of the EventID with the same checkbox name. I then take this string and put it into an array using Split which is also working fine. The section of the code that is giving an error is when I close the first recordset which Added the registrations and then open a new record set (of a different table, same Access database) and try to subtract 1 seat from the seats available. I&#039;ve looked all over and cannot find anything on this.<BR><BR>The section of code which is the problem looks like this:<BR><BR>Set objRS=Server.CreateObject("ADODB.Recordset")<BR>ob jRS.Open "tblSchedule", objConn, ,adLockOptimistic, adCmdTable<BR>Dim nSeats <BR>Do While Not objRS.EOF <BR> For iEventLoop=LBound(aEventArray) to UBound(aEventArray)<BR> IF objRS("EventID")=aEventArray(iEventLoop) Then<BR> nSeats=(objRS("SeatsAvail")-1)<BR> objRS("SeatsAvail")=nseats<BR> objRS.Update<BR> End If<BR> Next<BR>objRS.MoveNext<BR>Loop<BR>objRS.Close<BR>S et objRS=Nothing<BR><BR>If I just use the IF Then loop and go through and have it list the EventID and SeatsAvail fields, it works fine, but when I update SeatsAvail field, I get the following error:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers (0x80004005)<BR>Query-based update failed because the row to update could not be found.<BR><BR>Your help is greatly appreciated. I&#039;m sure its some little detail that I&#039;ve overlooked.<BR><BR>Thank you,<BR>Janice

  2. #2
    Join Date
    Dec 1969

    Default You are getting the error because.. have already closed the first recordset that has the <BR>(objRS("SeatsAvail") which is the number of seats available for the meeting.<BR>open a different recordset say objRS2 for the deletion of the seat from the second table and then close both the recordsets together. This should do.

Posting Permissions

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