|
 |
access_asp thread: Updating Database Part 2
Message #1 by "Robert Boczkay" <rboczkay@e...> on Tue, 23 Jul 2002 14:51:52
|
|
Sorry, one more question. I have the correct record being prepared to be
updated, but when I click submit, I get the following error. I already
have rsUpdateEntry though. ME == confused.
Rob
Microsoft VBScript runtime error '800a01a8'
Object required: 'rsUpdateEntry'
/rboczkay/BrinksterExamples/update_entry.asp, line 27
<%
'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 rsdatabase = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT * 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("NETID") = Request.Form("NETID")
'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 #2 by "Ganesh Danej" <gmdanej@i...> on Tue, 23 Jul 2002 15:25:37
|
|
> Sorry, one more question. I have the correct record being prepared to
be
u> pdated, but when I click submit, I get the following error. I already
h> ave rsUpdateEntry though. ME == confused.
> Rob
>
>
M> icrosoft VBScript runtime error '800a01a8'
> Object required: 'rsUpdateEntry'
> /rboczkay/BrinksterExamples/update_entry.asp, line 27
>
<> %
'> Dimension variables
D> im adoCon 'Holds the Database Connection Object
D> im rsdatabase 'Holds the recordset for the records in the database
D> im strSQL 'Holds the SQL query for the database
D> im RecordNo 'Holds the record number to be updated
> 'Read in the record number to be updated
R> ecordNo = Trim(Request.QueryString("ID"))
> 'Create an ADO connection object
S> et adoCon = Server.CreateObject("ADODB.Connection")
> 'Set an active connection to the Connection object using a DSN-less
c> onnection
a> doCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
S> erver.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
S> et rsdatabase = Server.CreateObject("ADODB.Recordset")
> 'Initialise the strSQL variable with an SQL statement to query the
d> atabase
s> trSQL = "SELECT * FROM Master_List WHERE NETID='" & RecordNo & "';"
> 'Set the cursor type we are using so we can navigate through the
recordset
r> sUpdateEntry.CursorType = 2
> 'Set the lock type so that the record is locked by ADO when it is updated
r> sUpdateEntry.LockType = 3
>
'> Open the recordset with the SQL query
r> sUpdateEntry.Open strSQL, adoCon
> 'Update the record in the recordset
r> sUpdateEntry.Fields("NETID") = Request.Form("NETID")
> 'Write the updated recordset to the database
r> sUpdateEntry.Update
> 'Reset server objects
r> sUpdateEntry.Close
S> et rsUpdateEntry = Nothing
S> et adoCon = Nothing
> 'Return to the update select page in case another record needs deleting
R> esponse.Redirect "select.asp"
%> >
check which is your ADO recordset object rsUpdateEntry or rsdatabase .
You have declare rsdatabase as
set rsdatabase = Server.CreateObject("ADODB.Recordset")
and you have used rsUpdateEntry for locking and updating
check it
Thanks
D.Gabnesh
Message #3 by "Robert Boczkay" <rboczkay@e...> on Tue, 23 Jul 2002 15:39:04
|
|
Now I get:
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
I changed the line 36 to
rsUpdateEntry.Fields("LASTNAME") = Request.Form("LAST")
where LASTNAME is the table column name and LAST is the form name.
|
|
 |