在asp中更新记录

时间:2014-07-07 01:37:20

标签: sql asp-classic

我在asp中添加了一些记录。但是,当我运行代码时,我看起来很问题:

  

ADODB.Recordset错误' 800a0cb3'

     

当前Recordset不支持更新。这可能是一个限制   提供者或选定的锁类型。

     

/adding.asp,第14行(rs1.addnew)

代码:

Dim MYSQL
Dim rs1
set conn1 = server.createobject("adodb.connection")
conn1.open "provider = microsoft.ace.oledb.12.0;data source =  C:\Users\nam2611\Documents\My Web Sites\WebSite1\Database3.accdb"
set rs1 = server.createobject("ADODB.Recordset")

MYSQL = "SELECT * FROM customer"

rs1.open MYSQL, conn1
rs1.addnew
rs1.Fields("customerID") = Request.form("custID")
rs1.Fields("Passcode") = Request.form("CPas")
rs1.Fields("customer_name") = Request.form("custname")
rs1.Fields("C_company") = Request.form("compname")
rs1.Fields("Phone_number") = Request.form("phone")
rs1.Fields("email") = Request.form("email")
rs1.Fields("C_adress_1") = Request.form("adress1")
rs1.Fields("C_adress_2") = Request.form("adress2")
rs1.Fields("C_post_code") = Request.form("Postcode")
rs1.Fields("C_Payment_info") = Request.form("payment")
rs1.update
rs1.close
set rs1 = nothing
response.write "added"
conn1.close

有人可以帮助我吗? 谢谢

1 个答案:

答案 0 :(得分:0)

请尝试以下代码:

...
MYSQL = "SELECT * FROM customer"

rs1.CursorLocation=adUseClient
rs1.CursorType=adOpenStatic
rs1.LockType=adLockBatchOptimistic

rs1.open MYSQL, conn1
...

或数字:

...
MYSQL = "SELECT * FROM customer"

rs1.CursorLocation=3
rs1.CursorType=3
rs1.LockType=4

rs1.open MYSQL, conn1
...