事务问题,提示我multiple recordsets .请高手指教...

babyshen 2009-06-30 03:52:05
set Errors=oConn.Errors

oConn.BeginTrans

sql = "Insert into E_Order (UserName,Company,Province,City,CompanyAddr,PostCode,Tel,Mobile,Contactor,Trans,createdDate) values('"&session("UserName")&"','"&request("Company")&"','"&request("province")&"','"&request("city")&"','"&request("companyaddr")&"','"&request("postcode")&"','"&request("tel")&"','"&request("mobile")&"','"&request("name")&"',"&request("trans")&",'"&Now()&"')"

oConn.execute(sql)

Set rs = oConn.Execute("SELECT SCOPE_IDENTITY() as newIDValue FROM E_Order")
newID = rs("newIDValue")

sql = "select UserName,productID,ProductCount from E_Cart where UserName='"&session("UserName")&"' order by createdDate desc"
Set rs1 = oConn.execute(sql)
While Not rs1.eof
sql1 = "insert into E_OrdertoProduct (OrderID,UserName,productID) values(" & newID & ",'"&session("UserName")&"'," & rs1("productID") &""
oConn.execute(sql1)
Wend

if Errors.Count > 0 then
oConn.RollbackTrans
oConn.close
' Response.Redirect ".asp"
response.write "rollback!"
else
oConn.commitTrans
oConn.close
response.write "commit"
End if

以上代码执行完,系统报错如下:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

Transaction cannot have multiple recordsets with this cursor type. Change the cursor type, commit the transaction, or close one of the recordsets.

/staff/serv/eBu/orderConfirm.asp, line 196

这里的196行就是我标红的那一行.但我必须要用查询啊..
有什么办法可以解决吗??
谢谢啦!!!
...全文
44 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧