p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Re: Microsoft VBScript runtime (0x800A01A8)


Message #1 by "Ken Schaefer" <ken@a...> on Fri, 14 Jun 2002 14:23:55 +1000
On line 33 you do this:
: set virusid = objRS("Virus_Item") + 1

whereas I think you want to do a "let". Change line 33 to:

virusid = objRS("Virus_Item") + 1

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Gary Schultz" <gschultz@n...>
Subject: [asp_databases] Microsoft VBScript runtime (0x800A01A8)


: Can't figure this one out, hoping someone else can
:
: getting the following error:
:
: Microsoft VBScript runtime (0x800A01A8)
: Object required: '[number: 3]'
: /etropy/submitviruschange.asp, line 35
:
: i'll supply entire code and delineate line 35:
:
: <%
: If request.Form("newentry") = "true" then
:
: dim objConn ' object for ADODB.Connection obj
: dim objRS ' object for output recordset object
: dim curDir ' .mdb file directory
:
: curDir = Server.MapPath("..\Datastore\etropy.mdb") ' Map
: database to virtual path
:
: set objConn=server.createobject("adodb.Connection") ' Create
: ADO Connection Component to connect with database
: objConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver
: (*.mdb)};DriverId=25;FIL=MS Access;"
:
: Set objRS = Server.CreateObject("ADODB.Recordset") ' Create
: ADO Recordset Component, and associate it with ADO connection
: Set objRS.ActiveConnection = objConn
:
: objRS.Source = "SELECT * FROM Viruses" ' Get recordset
: objRS.CursorType = adOpenStatic
:     objRS.LockType = adLockOptimistic
:     objRS.Open
:
: Dim virusid
: objRS.MoveLast
: set virusid = objRS("Virus_Item") + 1
:
: objRS.Addnew
: LINE 35--> objRS("Virus_Item") = virusid                   <--LINE 35
: objRS("Date") = request.Form("date") ' Change values in
: matching record
: objRS("Title") = request.Form("title")
: objRS("Description") = request.Form("description")
: objRS("Source") = request.Form("source")
: objRS("URL") = request.Form("url")
: objRS.Update
: objRS.Close
:
: set objRS = nothing
: set objConn = nothing
:
: response.Redirect("selectviruses.asp?action=newentry")
:
: Else
:
: dim virusitem
:
: curDir = Server.MapPath("..\Datastore\etropy.mdb") ' Map
: database to virtual path
:
: set objConn=server.createobject("adodb.Connection") ' Create
: ADO Connection Component to connect with database
: objConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver
: (*.mdb)};DriverId=25;FIL=MS Access;"
:
: Set objRS = Server.CreateObject("ADODB.Recordset") ' Create
: ADO Recordset Component, and associate it with ADO connection
: Set objRS.ActiveConnection = objConn
:
: objRS.Source = "SELECT * FROM Viruses WHERE Virus_Item LIKE '" &
: request.form("virusitem") & "'" ' Get recordset
: objRS.CursorType = adOpenStatic
:     objRS.LockType = adLockOptimistic
:     objRS.Open
:
: objRS("Title") = request.Form("title") ' Change values in
: matching record
:
: objRS.Update
: objRS.Close
:
: set objRS = nothing
: set objConn = nothing
:
: response.Redirect("selectviruses.asp?edit=complete")
:
: End If
: %>
:
: The intention of this snippet it to insert a new record into a table, the
: offending line relates to the primary key which is an autonumer field.
: I'm assuming that the ['number 3'] part of the error suggests that the
:
: Dim virusid
: objRS.MoveLast
: set virusid = objRS("Virus_Item") + 1
:
: code does return the right number as there are only two records at
: present thus the highest number in the primary key field is 2....2 + 1 
: well ya know :-)
:
: there is, of course an if...then it checks to see if i'm inserting a new
: record or updating an existing one...the ELSE is for updates
:
: Any help would be appreciated, this seems to be my last hurdle.  Thanks
: in advance.
:
: Gary Schultz

Message #2 by "Gary Schultz" <gschultz@n...> on Fri, 14 Jun 2002 03:25:16
Can't figure this one out, hoping someone else can

getting the following error:

Microsoft VBScript runtime (0x800A01A8)
Object required: '[number: 3]'
/etropy/submitviruschange.asp, line 35

i'll supply entire code and delineate line 35:

<%
	If request.Form("newentry")	= "true" then

	dim objConn 	' object for ADODB.Connection obj
	dim objRS 		' object for output recordset object
	dim curDir		' .mdb file directory
		
	curDir = Server.MapPath("..\Datastore\etropy.mdb")	' Map 
database to virtual path
	
	set objConn=server.createobject("adodb.Connection")	' Create 
ADO Connection Component to connect with database
	objConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver 
(*.mdb)};DriverId=25;FIL=MS Access;"

	Set objRS = Server.CreateObject("ADODB.Recordset")	' Create 
ADO Recordset Component, and associate it with ADO connection
	Set objRS.ActiveConnection = objConn
	
	objRS.Source = "SELECT * FROM Viruses"	' Get recordset
	objRS.CursorType = adOpenStatic
    objRS.LockType = adLockOptimistic
    objRS.Open
	
	Dim virusid
	objRS.MoveLast
	set virusid = objRS("Virus_Item") + 1
	
	objRS.Addnew
LINE 35-->	objRS("Virus_Item") = virusid                   <--LINE 35
	objRS("Date") = request.Form("date")	' Change values in 
matching record
	objRS("Title") = request.Form("title")	
	objRS("Description") = request.Form("description")
	objRS("Source") = request.Form("source")
	objRS("URL") = request.Form("url")
	objRS.Update
	objRS.Close
	
	set objRS = nothing
	set objConn = nothing
	
	response.Redirect("selectviruses.asp?action=newentry")
	
	Else
	
	dim virusitem
	
	curDir = Server.MapPath("..\Datastore\etropy.mdb")	' Map 
database to virtual path
	
	set objConn=server.createobject("adodb.Connection")	' Create 
ADO Connection Component to connect with database
	objConn.Open "DBQ="& curDir &";Driver={Microsoft Access Driver 
(*.mdb)};DriverId=25;FIL=MS Access;"

	Set objRS = Server.CreateObject("ADODB.Recordset")	' Create 
ADO Recordset Component, and associate it with ADO connection
	Set objRS.ActiveConnection = objConn
	
	objRS.Source = "SELECT * FROM Viruses WHERE Virus_Item LIKE '" & 
request.form("virusitem") & "'"	' Get recordset
	objRS.CursorType = adOpenStatic
    objRS.LockType = adLockOptimistic
    objRS.Open
	
	objRS("Title") = request.Form("title")	' Change values in 
matching record

	objRS.Update
	objRS.Close
	
	set objRS = nothing
	set objConn = nothing
	
	response.Redirect("selectviruses.asp?edit=complete")

	End If
%>

The intention of this snippet it to insert a new record into a table, the 
offending line relates to the primary key which is an autonumer field.  
I'm assuming that the ['number 3'] part of the error suggests that the

	Dim virusid
	objRS.MoveLast
	set virusid = objRS("Virus_Item") + 1

code does return the right number as there are only two records at 
present thus the highest number in the primary key field is 2....2 + 1 = 
well ya know :-)

there is, of course an if...then it checks to see if i'm inserting a new 
record or updating an existing one...the ELSE is for updates

Any help would be appreciated, this seems to be my last hurdle.  Thanks 
in advance.

Gary Schultz

  Return to Index