請教conn.execute("delete.....")

running_su 2003-01-03 11:51:08
conn.execute("delete.....")
運行了這條語句後,我想知道:
1。delete是否成功
2。刪除了多少條記錄

請教改如何做呢?
...全文
70 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
running_su 2003-01-03
  • 打赏
  • 举报
回复
select count(*)??假如我delete失敗了呢?這個法子怎麼行呢?
running_su 2003-01-03
  • 打赏
  • 举报
回复
隻能通過樓上的這種法子?conn.execute沒有返回什麼?有沒有更好的法子啊?
theghost 2003-01-03
  • 打赏
  • 举报
回复
在删除之前查询下就OK 了
select count(*)

yonghengdizhen 2003-01-03
  • 打赏
  • 举报
回复
你去select count(*) 一下看看还有没有符合条件的记录就对了..
lbd8848 2003-01-03
  • 打赏
  • 举报
回复
rs=conn.execute("select count(*) as c from table where 删除条件")
countrs=rs("c")
on error resume next
conn.execute("delete.....")
if err<>0 then
response.write "删除出错"
elseif isnull(countrs) then
response.write "您没有删除任何信息"
else
response.write "共删除" & countrs & "条记录"
end if
running_su 2003-01-03
  • 打赏
  • 举报
回复
lbd8848(lbd)的法子
顯然也不行err隻是判斷是否語法有錯而已,當我的sql語句沒有錯,但是刪除了一個不存在的記錄的時候,這個時候刪除也算不成功,對吧、?你的這個法子就判斷不出來是否刪除成功了。
如:
delete from 表 where id=1
但在表中id沒有1這個值的時候,這條語句就刪除不到任何東西了,然而這個時候的err還是等於0的
running_su 2003-01-03
  • 打赏
  • 举报
回复
ksy(一定要争气!!!)的:
set objRS=conn.execute(strSQL)
objRS.Count会返回执行SQL所影响的行数。


這個法子對select有用,對於delete,objRS.Count都是等於0的
lbd8848 2003-01-03
  • 打赏
  • 举报
回复
rs=conn.execute("select count(*) as c from table where 删除条件")
countrs=rs("c")
on error resume next
conn.execute("delete.....")
if err<>0 then
response.write "删除出错"
else
response.write "共删除" & countrs & "条记录"
end if
ksy 2003-01-03
  • 打赏
  • 举报
回复
set objRS=conn.execute(strSQL)
objRS.Count会返回执行SQL所影响的行数。

28,409

社区成员

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

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