Solved

updating recordsets

Posted on 1998-12-07
2
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

726 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