ash1984
05-10-2006, 01:53 PM
Hi
Bit of a noob when it comes to asp so any help is very much apreciated.
Keep getting a ADODB.Recordset (0x800A0BCD) BOf or EOF error when trying to update an access database via sql.
below is my code, please help.
<% @ LANGUAGE = VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<% 'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsUpdateEntry '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("Employee_ID"))
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Employee.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=Employee"
'Create an ADO recordset object
Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblEmployee.* FROM tblEmployee WHERE Employee_ID=" & lngRecordNo
'Set the cursor type we are using so we can navigate through the recordset
rsUpdateEntry.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsUpdateEntry.LockType = 3
'Open the recordset with the SQL query
rsUpdateEntry.Open strSQL, adoCon
'Update the record in the recordset
rsUpdateEntry.Fields("Name") = Request.Form("Name")
rsUpdateEntry.Fields("HouseNoName") = Request.Form("HouseNoName")
rsUpdateEntry.Fields("StreetAddress") = Request.Form("StreetAddress")
rsUpdateEntry.Fields("CityTown") = Request.Form("CityTown")
rsUpdateEntry.Fields("County") = Request.Form("County")
rsUpdateEntry.Fields("PostCodeOut") = Request.Form("PostCodeOut")
rsUpdateEntry.Fields("PostCodeIn") = Request.Form("PostCodeIn")
rsUpdateEntry.Fields("Age") = Request.Form("Age")
rsUpdateEntry.Fields("PhoneNo") = Request.Form("PhoneNo")
rsUpdateEntry.Fields("DateOfBirth") = Request.Form("DateOfBirth")
rsUpdateEntry.Fields("Email") = Request.Form("Email")
'Write the updated recordset to the database
rsUpdateEntry.Update
'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing
'Return to the update select page in case another record needs deleting
Response.Redirect "update_select.asp"
%>
</body>
</html>
Bit of a noob when it comes to asp so any help is very much apreciated.
Keep getting a ADODB.Recordset (0x800A0BCD) BOf or EOF error when trying to update an access database via sql.
below is my code, please help.
<% @ LANGUAGE = VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<% 'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsUpdateEntry '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("Employee_ID"))
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Employee.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=Employee"
'Create an ADO recordset object
Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT tblEmployee.* FROM tblEmployee WHERE Employee_ID=" & lngRecordNo
'Set the cursor type we are using so we can navigate through the recordset
rsUpdateEntry.CursorType = 2
'Set the lock type so that the record is locked by ADO when it is updated
rsUpdateEntry.LockType = 3
'Open the recordset with the SQL query
rsUpdateEntry.Open strSQL, adoCon
'Update the record in the recordset
rsUpdateEntry.Fields("Name") = Request.Form("Name")
rsUpdateEntry.Fields("HouseNoName") = Request.Form("HouseNoName")
rsUpdateEntry.Fields("StreetAddress") = Request.Form("StreetAddress")
rsUpdateEntry.Fields("CityTown") = Request.Form("CityTown")
rsUpdateEntry.Fields("County") = Request.Form("County")
rsUpdateEntry.Fields("PostCodeOut") = Request.Form("PostCodeOut")
rsUpdateEntry.Fields("PostCodeIn") = Request.Form("PostCodeIn")
rsUpdateEntry.Fields("Age") = Request.Form("Age")
rsUpdateEntry.Fields("PhoneNo") = Request.Form("PhoneNo")
rsUpdateEntry.Fields("DateOfBirth") = Request.Form("DateOfBirth")
rsUpdateEntry.Fields("Email") = Request.Form("Email")
'Write the updated recordset to the database
rsUpdateEntry.Update
'Reset server objects
rsUpdateEntry.Close
Set rsUpdateEntry = Nothing
Set adoCon = Nothing
'Return to the update select page in case another record needs deleting
Response.Redirect "update_select.asp"
%>
</body>
</html>