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
    Regular Coder
    Join Date
    Jul 2002
    Location
    Bunbury W.A
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    con.execute insert problem

    Can someone see what the problem with this is, the error keeps coming but it looks right
    Microsoft VBScript runtime (0x800A01A8)
    Object required: 'con'
    /wic/contact/add_Pcontact.asp, line 29

    (line 29 is con.execute line)

    <%
    con="DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=" & Server.MapPath(level&"../db/wic.mdb") & ";"

    Condate=request.form("Condate")
    txtHuman=request.form("Human")
    txtHissue=request.form("Hissue")
    numPolicy=request.form("Policy")
    txtnotes =request.form("Notes")
    submitval=request.form("Submit")
    id=request("id")
    if (submitval="Submit") then
    set rs = Server.Createobject("ADODB.Recordset")
    sql = "select * from pcontact"
    rs.open sql, con
    if rs.BOF then
    con.execute("Insert into pcontact(DateP,Human,HealthIssue,PolicyId,Notes) values(#"&Condate&"#,'"&txtHuman&"','"&txtHissue&"','"&numPolicy&"','"&txtnotes&"')")
    response.redirect "pcontact.asp?msg=Successfully Added"
    end if
    end if

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Hong Kong
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try something like this:

    set rs = con.execute("Insert into pcontact(DateP,Human,HealthIssue,PolicyId,Notes) values(#"&Condate&"#,'"&txtHuman&"','"&txtHissue&"','"&numPolicy&"','"&txtnotes&"')")

    Maybe it will works
    From the error message, the problems lie on the database connection.

    I usually set my connection in this way:

    Set Con = Server.CreateObject("ADODB.Connection")
    Con.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("\Folder") & "\database.mdb"
    ....
    ....
    Con.Close
    Set rs = Nothing
    Set Con = Nothing

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Bunbury W.A
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    isnt that strange?

    Well thansk very much thats fixed it.
    Id really like to know why mine did not work, just for the exersise
    thanks heaps
    daz


  •  

    Posting Permissions

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