asp写库的具体数据如何response.write出来呢?

iou3344 2016-02-26 09:30:59
我的程序大概是这样写的(实际情况是外面还套了一层循环,但是不涉及写库动作,所以就没列出来~)

<%
'title 字段是nvarchar(255)
'title_numb 字段是int

title="这是 从其 他页 面传进 来 的用 于搜 素 这个 字段 title 的各种 搜 索关 键词"
value=replace(title," ",",")'空格替换为半角逗号
arr=split(value,",")'拆分得到数组
for j=0 to ubound(arr)
sql=""
sql = "select title,title_numb from [search] where title='" & arr(j) & "'"
rs.Open sql, conn, 1, 3
if not rs.eof then
rs("title_numb") = rs("title_numb")+1
rs.update
else
rs.addnew
rs("title") = title
rs("title_numb") = rs("title_numb")+1
rs.update
end if
rs.Close
next
%>


我在想,能不能把写库时发生的动作和写库的内容等等全部response.write出来呢?以便我好看看每一次执行rs.update时都发生了些什么。。以便我找出我遇到的问题的原因!

之所以要这样做是因为我另外一个帖子 请看~~ http://bbs.csdn.net/topics/391907740

@无聊码农
...全文
172 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
iou3344 2016-02-26
  • 打赏
  • 举报
回复
引用 1 楼 showbo 的回复:
没有属性能获取到更新或中插入的sql语句,你一定要打印,可以自己构造sql语句,然后conn.execute来执行
title="这是 会 出现 的 是 我 的各 种搜 索关 键词"
value=replace(title," ",",")'空格替换为半角逗号
arr=split(value,",")'拆分得到数组
    for j=0 to ubound(arr)
      sql=""
      sql = "select title,title_numb,id列 from [search]  where title='" & arr(j) & "'"
      rs.Open sql, conn, 1, 3
    if not rs.eof then
    sql="update [search] set title_numb=title_numb+1  where title='" & arr(j) & "'"
'rs("title_numb") = rs("title_numb")+1
      '  rs.update
    else
    sql="insert into [search](title,title_numb)values('"&arr(j)&"',1)"'插入的应该是arr(j)吧,你怎么插入了title?不是分割后的关键字??
       ' rs.addnew
       ' rs("title") = title
'rs("title_numb") = rs("title_numb")+1
       ' rs.update
end if
    response.write sql&"<BR>"'打印sql
    conn.execute(sql)'和rs.update差不多一个意思

      rs.Close
    next
@showbo showbo版主,你说聪明做的吗?为什么这么这么这么聪明么。。。
Go 旅城通票 2016-02-26
  • 打赏
  • 举报
回复
sql = "select title,title_numb from [search] where title='" & arr(j) & "'" sql改这样,去掉id列。。你的主键是关键字。。
Go 旅城通票 2016-02-26
  • 打赏
  • 举报
回复
没有属性能获取到更新或中插入的sql语句,你一定要打印,可以自己构造sql语句,然后conn.execute来执行
title="这是 会 出现 的 是 我 的各 种搜 索关 键词"
value=replace(title," ",",")'空格替换为半角逗号
arr=split(value,",")'拆分得到数组
    for j=0 to ubound(arr)
      sql=""
      sql = "select title,title_numb,id列 from [search]  where title='" & arr(j) & "'"
      rs.Open sql, conn, 1, 3
    if not rs.eof then
    sql="update [search] set title_numb=title_numb+1  where title='" & arr(j) & "'"
'rs("title_numb") = rs("title_numb")+1
      '  rs.update
    else
    sql="insert into [search](title,title_numb)values('"&arr(j)&"',1)"'插入的应该是arr(j)吧,你怎么插入了title?不是分割后的关键字??
       ' rs.addnew
       ' rs("title") = title
'rs("title_numb") = rs("title_numb")+1
       ' rs.update
end if
    response.write sql&"<BR>"'打印sql
    conn.execute(sql)'和rs.update差不多一个意思

      rs.Close
    next

28,390

社区成员

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

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