|
-
Jul 7th, 2001, 04:58 PM
#1
Thread Starter
Member
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
-
Jul 7th, 2001, 05:00 PM
#2
Well if you would tell us which line it would help!
callerID = rsCallers.Fields("CallerID").Value
take off all the .Value in your code
-
Jul 8th, 2001, 01:45 PM
#3
Hyperactive Member
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")
-
Jul 9th, 2001, 06:43 AM
#4
Black Cat
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.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|