首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 请帮我看下这段sql语句 [已结贴,结贴人:bananakk]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 15:53:58 楼主
    <%Set rrs= Server.CreateObject("abodb.recordset")
    sql="select * from gexinghua where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'"
    rrs.open sql,conn,3,3
    if not rrs.eof then
    conn.execute("update gexinghua set js=js+1 where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'")
    else
    conn.execute("insert into gexinghua (js,huiyuan,lbid) values(1,'"&session("huiyuan")&"','"&rs("lbid")&"')")
    end if
    %>
    为什么这样运行的时候后面那个insert就运行不出来,把前面那些都去掉,才能运行insert?
    10  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 16:11:331楼 得分:0
    VBScript code
    <% ' 首先你得明白这段程序的逻辑和功能 Set rrs= Server.CreateObject("abodb.recordset") sql="select * from gexinghua where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'" rrs.open sql,conn,3,3 ' if语句的存在让update和insert只能由一个执行 if not rrs.eof then conn.execute("update gexinghua set js=js+1 where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'") else conn.execute("insert into gexinghua (js,huiyuan,lbid) values(1,'"&session("huiyuan")&"','"&rs("lbid")&"')") end if %>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 16:31:452楼 得分:0
    我本来就是要运行一个出来啊,问题是条件不符合,也只运行if,不运行else条件,怎么回事
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 16:48:083楼 得分:0
    VBScript code
    <% ' 建议这样写 Set rrs= Server.CreateObject("abodb.recordset") sql="select * from gexinghua where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'" rrs.open sql,conn,3,3 if rrs.eof or rrs.bof then conn.execute("insert into gexinghua (js,huiyuan,lbid) values(1,'"&session("huiyuan")&"','"&rs("lbid")&"')") else conn.execute("update gexinghua set js=js+1 where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'") end if %>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 16:55:114楼 得分:10
    因为rrs不是eof,当然跑不到else
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 17:10:245楼 得分:0
    照三楼的改完后,只运行insert条件了.
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-05-22 17:23:476楼 得分:0
    终于改对了,谢谢大家的帮忙.
    <%
    Set rs= Server.CreateObject("abodb.recordset") 
    set rrs=conn.execute("select * from gexinghua where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'") 
    if not rrs.eof then 
    set rrs=conn.execute("update gexinghua set js=js+1 where huiyuan='"&session("huiyuan")&"' and lbid='"&rs("lbid")&"'") 
    else 
    set rrs=conn.execute("insert into gexinghua (js,huiyuan,lbid) values(1,'"&session("huiyuan")&"','"&rs("lbid")&"')") 
    end if 
    %> 
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved