Solved

updating recordsets

Posted on 1998-12-07
2
184 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
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 viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now