Results 1 to 4 of 4

Thread: Object required?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2001
    Location
    St. Louis, Missouri
    Posts
    49

    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

  2. #2
    chenko
    Guest
    Well if you would tell us which line it would help!

    callerID = rsCallers.Fields("CallerID").Value

    take off all the .Value in your code

  3. #3
    Hyperactive Member
    Join Date
    Apr 2001
    Posts
    315
    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")

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    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
  •  



Click Here to Expand Forum to Full Width