PDA

View Full Version : con.execute insert problem



dawilis
11-01-2003, 12:13 AM
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

victoria_1018
11-03-2003, 07:37 AM
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

dawilis
11-03-2003, 07:56 AM
Well thansk very much thats fixed it.
Id really like to know why mine did not work, just for the exersise
thanks heaps
daz