我有这段代码:
Set oConnection = Server.CreateObject("ADODB.Connection")
Set oRecordset = Server.CreateObject("ADODB.Recordset")
oConnection.Open "DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;UID=xxxx;PWD=xxxx;DATABASE=xxxx; OPTION=3;"
Sqltemp = "INSERT INTO rsvptable (fname, lname, fbid, rsvp, streetaddress, city, state, zip, streetaddress2, cellphone, acode) " & _
"VALUES ('" & firstName & "', '" & lastName & "', " & fb & ", 0, '" & address1 & "', '" & city & "', '" & strState & "', " & zip & ", '" & address2 & "', " & cell & ", " & returnedNums & ")"
set newAdd = oConnection.execute(Sqltemp)
if newAdd.EOF then
response.write "end"
else
response.write "not end"
end if
它一直告诉我这个:
ADODB.Recordset错误'800a0e78'
关闭对象时不允许操作。
/add.asp,第136行
第136行是这样的:
if newAdd.EOF then
我会在这里俯瞰什么?
更新
在这里找到我的答案! :O)
答案 0 :(得分:1)
http://www.w3schools.com/ado/met_conn_execute.asp
如果是结果,则结果存储在新的Recordset对象中 行返回查询。如果是,则返回一个关闭的Recordset对象 不是行返回查询。
INSERT不是行返回查询,因此它返回一个已关闭的记录集,因此您不能.EOF
它。检查受影响的行,将变量作为第二个参数传递给Execute
。如果RowsAffected为1,则表示您已设置。
答案 1 :(得分:1)
两件事:
oRecordset
定义为记录集,但随后使用&在newAdd