Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Field (0x80020009) Either BOF or EOF is True, or the current rec

Status
Not open for further replies.
Dec 8, 2011
3
US
Hello, I'm getting the above error with the below code, can someone please help me see where the error is? I'm about to go seriously crazy, thanks so much in advance:

<% 'Dimension variables
Dim adoConnect 'Holds the Database Connection Object
Dim rsEmployees 'Holds the recordset for the record to be updated
Dim strSQL 'Holds the SQL query to query the database
Dim lngRecordNo 'Holds the record number to be updated

'Read in the record number to be updated
lngRecordNo = CLng(Request.Form(ID))

'Create an ADO connection object
Set adoConnect = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoConnect.Open = "DBQ="&Server.MapPath("/DEV")&"\EmployeesDB.mdb;Driver={Microsoft Access Driver (*.mdb)}"

'Create an ADO recordset object
Set rsEmployees = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM Employees_Table WHERE ID=" & lngRecordNo

'Set the cursor type we are using so we can navigate through the recordset
rsEmployees.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsEmployees.LockType = 3

'Open the recordset with the SQL query
rsEmployees.Open strSQL, adoConnect

'Update the record in the recordset
rsEmployees.Fields("First_Name") = Request.Form("First_Name")
rsEmployees.Fields("Last_Name") = Request.Form("Last_Name")
rsEmployees.Fields("Domain_Username") = Request.Form("Domain_Username")
rsEmployees.Fields("Domain_Password") = Request.Form("Domain_Password")
rsEmployees.Fields("E-mail_Password") = Request.Form("E-mail_Password")
rsEmployees.Fields("Email_Address") = Request.Form("Email_Address")
rsEmployees.Fields("Phone_Number") = Request.Form("Phone_Number")


'Write the updated recordset to the database
rsEmployees.Update

'Reset server objects
rsEmployees.Close
Set rsEmployees = Nothing
Set adoConnect = Nothing

'Return to the update select page in case another record needs editing
Response.Redirect "SelectEmployeetoUpdate.asp"
%>
 
Check your query to make sure it is returning at least one record.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Hi ChrisHirst,

Thanks for you reply, I checked my query and the statement that was returned was:
SELECT * FROM Employees_Table WHERE ID=0
I don't understand why this is since I have the record ID in a hidden field and the labeling is properly typed.

It's worth mentioning that the ID field on the database is an auto-number, could that be the reason for the error? if so how do I fix this? any help would be appreciated.
 
Hi,
If ID is an Autonumber and IngRecordNo is 0 then no records will be returned since ( If I recall) Autonumber fields start with 1.

Try displaying the results of
lngRecordNo = CLng(Request.Form(ID))

before executing the query.

[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Yep, by default Access auto numbering starts at 1, so the next stage of debugging is see what the form value is on submit.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Thanks everyone, my mistake was that I was referencing a bad link on the form post method.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top