百思不得其解,是我代码的问题,还是access数据库的问题

xshuiniu 2003-08-19 03:39:50
网站原来是sql server数据库,后因需要改成access的,可是原本运行的好好的程序现在报错了,是一段删除记录的程序
<!--#include file="Connection.asp" -->
<%
Response.expires = 0
on error resume next
if Session("right")<1 then
response.end
end if
a=request.form(1)

'读出要删除id的列表
if isnull(a) or len(a)<1 then
response.end
end if


parmarray=split(a,",")
sheet=request("sheet")
'读出要删除的表名
set conn = Server.CreateObject("ADODB.Connection")
conn.open connst
conn.BeginTrans

for i=0 to ubound(parmarray)
sql="delete from " & sheet & " where id='" & parmarray(i) & "'"
conn.execute(sql)
next

if conn.errors.count > 0 then
conn.rollbacktrans

conn.close
set conn = nothing
response.write "<center>写数据库出现异常错误,请再试一次!</center><br>"
response.write "<center><a href='' onclick='history.back(1)'>返回</a></center>"
response.end
else
conn.committrans

conn.close
set conn = nothing

end if
%>



-----------------------
报的错就是:写数据库出现异常错误,请再试一次!,不知道是什么原因,大家帮忙看看,谢谢
...全文
67 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xshuiniu 2003-08-19
  • 打赏
  • 举报
回复
呵呵,结贴,还真是单引号的原因,没看到,:(

花了我几个小时的时间,55555
lions911 2003-08-19
  • 打赏
  • 举报
回复
一定是字段类型错误,改了就行
damboo 2003-08-19
  • 打赏
  • 举报
回复
我以前把SQL数据库倒出到MDB文件
结果index没了,自动增量的字段全都变成int
这样一来就全都用不了了
不知道是不是这个原因
jiejifeng 2003-08-19
  • 打赏
  • 举报
回复
去掉id 中的单引号
wsmall 2003-08-19
  • 打赏
  • 举报
回复
两个问题,1、id的数据类型
2、你的const是什么东西?检查一下,连接字是不是正确。

再ACCESS中是可以用事务处理的,我用过
Brookes 2003-08-19
  • 打赏
  • 举报
回复
错误信息是你自己的呀!去掉on error resume next,看看到底出了啥问题!
antheayao 2003-08-19
  • 打赏
  • 举报
回复
connst是DSN?
先看看你的数据源配置好了吗,然后在看看楼上说的
huiyuehuiyue 2003-08-19
  • 打赏
  • 举报
回复
for i=0 to ubound(parmarray)
sql="delete from " & sheet & " where id=" & parmarray(i) conn.execute(sql)
next

去掉单引号
qjrein 2003-08-19
  • 打赏
  • 举报
回复
"delete * from " & sheet & " where id="+cstr(parmarray(i))
qjrein 2003-08-19
  • 打赏
  • 举报
回复
delete * from " & sheet & " where id='" & parmarray(i) & "'"
试试看
cloudchen 2003-08-19
  • 打赏
  • 举报
回复
id不是int型的?怎么加了引号?
xxrl 2003-08-19
  • 打赏
  • 举报
回复
access好像不支持事务交易

28,390

社区成员

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

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