|
 |
access_asp thread: ASP/SQL Question/Dilemma
Message #1 by "Robert Boczkay" <rboczkay@e...> on Tue, 23 Jul 2002 18:32:03
|
|
Why do I get the following error:
ADODB.Recordset error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.
/rboczkay/BrinksterExamples/update_entry.asp, line 36
FOR this page of code:
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsdatabase 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim RecordNo 'Holds the record number to be updated
'Read in the record number to be updated
RecordNo = Trim(Request.QueryString("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("\rboczkay\db\database.mdb")
'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=database"
'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 Master_List.* FROM Master_List WHERE NETID='" & RecordNo
& "';"
'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("LASTNAME") = Request.Form("LAST")
rsUpdateEntry.Fields("FIRSTNAME") = Request.Form("FIRST")
'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 "select.asp"
%>
-THANKS in advance - Rob
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 24 Jul 2002 12:59:22 +1000
|
|
Because your SQL statement isn't returning any records.
Suggest you do this:
<%
strSQL = "SELECT Master_List.* FROM Master_List WHERE NETID='" & RecordNo
& "';"
Response.Write(strSQL)
Response.End
%>
and look at the outputted SQL statement. You can then run it inside Access
to verify if it returns any records...
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Robert Boczkay" <rboczkay@e...>
Subject: [access_asp] ASP/SQL Question/Dilemma
: Why do I get the following error:
:
: ADODB.Recordset error '800a0bcd'
:
: Either BOF or EOF is True, or the current record has been deleted.
: Requested operation requires a current record.
:
: /rboczkay/BrinksterExamples/update_entry.asp, line 36
:
: FOR this page of code:
:
: <%
: 'Dimension variables
: Dim adoCon 'Holds the Database Connection Object
: Dim rsdatabase 'Holds the recordset for the records in the database
: Dim strSQL 'Holds the SQL query for the database
: Dim RecordNo 'Holds the record number to be updated
:
: 'Read in the record number to be updated
: RecordNo = Trim(Request.QueryString("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("\rboczkay\db\database.mdb")
:
: 'Set an active connection to the Connection object using DSN connection
: 'adoCon.Open "DSN=database"
:
: '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 Master_List.* FROM Master_List WHERE NETID='" & RecordNo
: & "';"
:
: '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("LASTNAME") = Request.Form("LAST")
: rsUpdateEntry.Fields("FIRSTNAME") = Request.Form("FIRST")
:
: '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 "select.asp"
: %>
Message #3 by "Robert Boczkay" <rboczkay@e...> on Wed, 24 Jul 2002 13:04:20
|
|
I know it isn't and I've had tens of people try to help me figure out a
correct statement to put and nothing will work. Frustrating beyond
belief. I still have hope that someone out there knows how to fix this
snafu!
Message #4 by "Ken Schaefer" <ken@a...> on Thu, 25 Jul 2002 11:13:38 +1000
|
|
Hi Robert,
Can you please do as I asked:
<%
strSQL = "SELECT Master_List.* FROM Master_List WHERE NETID='" & RecordNo
& "';"
Response.Write(strSQL)
Response.End
%>
This will output the actual SQL you are sending to the database to the
screen. Sometimes what is wrong is obvious at this point. If it is still not
obvious what is wrong, you can cut-n-paste the statement into the Access QBE
(Queries | New in Designer | SQL View), and attempt to run it. Access will
usually tell you what is wrong if there is something wrong...
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Robert Boczkay" <rboczkay@e...>
Subject: [access_asp] Re: ASP/SQL Question/Dilemma
: I know it isn't and I've had tens of people try to help me figure out a
: correct statement to put and nothing will work. Frustrating beyond
: belief. I still have hope that someone out there knows how to fix this
: snafu!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |