Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2005
    Location
    Laguna, Philippines
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help please.... please

    can you tell what might be the problem here?
    the error is - ADODB.Recordset (0x800A0E78)
    Operation is not allowed when the object is closed.
    ctr and cnt are variables, cone is my adodb.connection

    for ctr = 0 to cnt
    set vanny=server.createobject("adodb.recordset")
    p = prod(ctr)
    q = quan(ctr)
    c = cost(ctr)

    sql = "insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "','" & q & "'," & md & "," & c & ")"
    vanny.open sql, cone
    vanny.close
    set vanny = nothing
    Next
    "It is the unknown we fear when we look upon death and darkness, nothing more!"-- Albus Dumbledore

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Umm. Why are you using a recordset to do an insert? It's unnecessary.

    Your error is probably because the connection isn't open.

    Code:
    set myConnection = server.createobject("ADODB.Connection")
    myConnection.open myConnectionStringOrDSN
    
    for ctr = 0 to cnt
    p = prod(ctr)
    q = quan(ctr)
    c = cost(ctr)
    intRowsAffected = 0
    
    sql = "insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "','" & q & "'," & md & "," & c & ")"
    myConnection.execute sql, intRowsAffected
    if intRowsAffected then
    'SQL executed successfully
    else
    'SQL failed
    end if
    Next
    
    myConnection.close
    set myConnection = nothing

  • #3
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,062
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Code:
    for ctr = 0 to cnt
       p = prod(ctr)
       q = quan(ctr)
       c = cost(ctr)
    
       cone.execute("insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "','" & q & "'," & md & "," & c & ")")
    Next
    cone.close
    set cone = nothing
    however wouldn't your database column quantity have a datatype of number? in which case you would not have the single quotes around the q
    Code:
    for ctr = 0 to cnt
       p = prod(ctr)
       q = quan(ctr)
       c = cost(ctr)
    
       cone.execute("insert into orderinvent (clientcode, product, quantity, dateorder, price) values (" & code & ",'" & p & "'," & q & "," & md & "," & c & ")")
    Next
    cone.close
    set cone = nothing


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •