Solved

updating recordsets

Posted on 1998-12-07
2
187 Views
Last Modified: 2013-12-25
I need to allow users to update/modify Access records throught a browser. They search with a form (based on a primary key in Access) and when the result shows up, they can modify as they need. The only things I know about ASPs is form the Beginning and Professional Active Server Pages 2.0 books from Wrox Press.

Here's the code where the error lies:
-------------------------------------
        ' name of this file is /boogie/modifyresults.asp
        dim primary_key
      ' create the recordset object
      Set objRec = Server.CreateObject ("ADODB.Recordset")

      ' open the recordset object (tried w/o Batch also)
      objRec.Open "MyDB", strConnect, adOpenKeyset, _
            adLockBatchOptimistic, adCmdTable

      primary_key = Request.Form("Primary_key")
        ' find the record with the primary key they entered
      objRec.Find "Primary_key = 'primary_key'", 0, _
                  adSearchForward
      If objRec.EOF Then
         objRec("Field2") = Request.Form("NewField2")
         objRec("Field3") = Request.Form("NewField3")
           .....
      objRec.UpdateBatch    'tried without the Batch also
      Else
        Response.Write "Couldn't find the record<BR>"
      End If
      
      ' now close and clean up
      objRec.Close
      Set objRec = Nothing
-------------------------------------

The error message I get is
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.

/boogie/modifyresults.asp, line 40

MS's Knowledge Base didn't help. Line 40 of the file is:
         objRec("Field2") = Request.Form("NewField2")

Please help ASAP. Thanks.
0
Comment
Question by:Pakfan
2 Comments
 
LVL 1

Accepted Solution

by:
suden earned 150 total points
ID: 1856946
Hi,

Change your following code

If objRec.EOF AND objRec.BOF Then
   objRec("Field2") = Request.Form("NewField2")
   objRec("Field3") = Request.Form("NewField3")
           .....
objRec.UpdateBatch    'tried without the Batch also
Else
  Response.Write "Couldn't find the record<BR>"
End If


in ADO if recordset is empty then both eof and box are true so to check that you have any record in your recordset you should check both EOF and BOF.

Suden
0
 

Author Comment

by:Pakfan
ID: 1856947
That gets rid of the error message for the time being but the record does not get updated. According to the book, it looks like I had the actions reversed. Apparently, the line
   objRec("Field2") = Request.Form("NewField2")
should be in the Else statement, not in the If part. Either way, the recordset does not get updated. Thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question