-
Object required?
I am a regular VB user and am working on making my code work for ASP as well. I have created the following script that gives me an object required error. Can anyone tell me what I have done wrong?
Code:
<%
dim myconnection
dim connectstring
dim strSQL
dim rsCallers
dim rsSponsorList
dim name
dim address
dim phone
dim sponsorID
dim caller
dim callerID
dim response
dim calldate
connectstring = "Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\SourceCode\VBUG\JobFair.mdb;"
set myconnection = server.createobject("ADODB.Connection")
set rsCallers = server.createobject("ADODB.Recordset")
set rsSponsorList = server.createobject("ADODB.Recordset")
myconnection.open connectstring
name = request.form("Name")
address = request.form("Address")
phone = request.form("Phone")
calldate = request.form("CallDate")
response = request.form("Response")
caller = request.form("Caller")
strSQL = "insert into Sponsors (Name, Address, Phone) values ('" & name & "', '" & address & "', '"& phone & "')"
myconnection.execute(strSQL)
strSQL = ""
strSQL = "select MAX(SponsorID) as NewID from Sponsors"
set rsSponsorList = myconnection.execute(strSQL)
sponsorID = rsSponsorList.Fields("NewID").Value
strSQL = ""
strSQL = "Select CallerID from Callers where CallerName = " & caller
set rsCallers = myconnection.execute(strSQL)
callerID = rsCallers.Fields("CallerID").Value
strSQL = ""
strSQL = "insert into CallInfo (SponsorID, CallerID, Response, CallDate) values (" & sponsorID & ", " & callerID & ", '" & response & "', " & calldate & ")"
myconnection.execute(strSQL)
%>
Also, I have to admit being *very* new to this so if you need more information or if I am asking too much at once, please let me know.
Thank you!
Eva
-
Well if you would tell us which line it would help!
callerID = rsCallers.Fields("CallerID").Value
take off all the .Value in your code
-
Note. This two sets are a waste of time since you SET the
objects again later. You are creating an object only to have it
destroyed by a later SET.
set rsCallers = server.createobject("ADODB.Recordset")
set rsSponsorList = server.createobject("ADODB.Recordset")
-
Stick an "Option Explicit" at the top of your code. There might just be a typo in it.
chenko, I think using the .Value should be fine, as without it you're actually dealing with the default value for a pointer to a Field object.