查看: 1147|回复: 4

[问与答] 求高手指点

[复制链接]
胡彬 发表于 2019-7-17 17:01:59 | 显示全部楼层 |阅读模式
set rs=server.createobject("ADODB.RecordSet")
sql="select * from produit where huohao='"&nowhuohao&"' and id_ku="&nowku
rs.open sql,conn,1,3
  if rs("kuwei")<>nowkuwei then
  rs.addnew
  rs("id_bigclass")=rs_produit("id_bigclass")
  rs("id_smallclass")=rs_produit("id_smallclass")
  rs("title")=rs_produit("title")
  rs("huohao")=rs_produit("huohao")
  rs("id_ku")=rs_produit("id_ku")
  rs("kuwei")=nowkuwei
  rs("shulian")=nowshulian
  rs("danwei")=rs_produit("danwei")
  rs("price")=rs_produit("price")
  rs("price2")=nowpinprice2
  rs("guige")=rs_produit("guige")
  rs("tm")=rs_produit("tm")
  rs("sl")=rs_produit("sl")
  rs("zl")=rs_produit("zl")
  rs("tz")=rs_produit("tz")
  rs("baojin")=rs_produit("baojin")
  rs("class")=rs_produit("class")
  rs("duihuan")=rs_produit("duihuan")
  rs("tichen_type")=rs_produit("tichen_type")
  rs("tichen")=rs_produit("tichen")
  rs("photo")=rs_produit("photo")
  rs("beizhu")=rs_produit("beizhu")
  rs("gys")=rs_produit("gys")
    else   
rs("shulian")=rs("shulian")+nowshulian
  rs("price2")=nowpinprice2
  rs.update
end if
这个当货号与库位与记录相同时,进行更新数量价格,否则新增记录,测试有时可以有时不行,不知什么问题,请高手帮忙呀,新手
xuanxiao 发表于 2019-7-17 20:30:44 | 显示全部楼层
  1. <%
  2. set rs=server.createobject("ADODB.RecordSet")
  3. sql="select * from produit where huohao='"&nowhuohao&"' and id_ku="&nowku
  4. rs.open sql,conn,1,3
  5. if  rs.eof then
  6. rs.addnew
  7.   rs("id_bigclass")=rs_produit("id_bigclass")
  8.   rs("id_smallclass")=rs_produit("id_smallclass")
  9.   rs("title")=rs_produit("title")
  10.   rs("huohao")=rs_produit("huohao")
  11.   rs("id_ku")=rs_produit("id_ku")
  12.   rs("kuwei")=nowkuwei
  13.   rs("shulian")=nowshulian
  14.   rs("danwei")=rs_produit("danwei")
  15.   rs("price")=rs_produit("price")
  16.   rs("price2")=nowpinprice2
  17.   rs("guige")=rs_produit("guige")
  18.   rs("tm")=rs_produit("tm")
  19.   rs("sl")=rs_produit("sl")
  20.   rs("zl")=rs_produit("zl")
  21.   rs("tz")=rs_produit("tz")
  22.   rs("baojin")=rs_produit("baojin")
  23.   rs("class")=rs_produit("class")
  24.   rs("duihuan")=rs_produit("duihuan")
  25.   rs("tichen_type")=rs_produit("tichen_type")
  26.   rs("tichen")=rs_produit("tichen")
  27.   rs("photo")=rs_produit("photo")
  28.   rs("beizhu")=rs_produit("beizhu")
  29.   rs("gys")=rs_produit("gys")
  30. else
  31.   rs("shulian")=rs("shulian")+nowshulian
  32.   rs("price2")=nowpinprice2
  33. end if

  34. rs.update
  35. rs.close
  36. set rs=nothing
  37. %>
复制代码
 楼主| 胡彬 发表于 2019-7-19 09:43:53 | 显示全部楼层

谢谢,十分感谢
这样是能更新数量与单价,我的意思是当我输入的Kuwei字段值会与记录集数据库中相同时,执行更新数量与单价,如当前输入的Kuwei值与记录集数据库中不相同时,则新增新记录,条件比对要在相同货号的基础上
ttasp 发表于 2019-7-19 10:14:30 | 显示全部楼层
胡彬 发表于 2019-7-19 09:43
谢谢,十分感谢
这样是能更新数量与单价,我的意思是当我输入的Kuwei字段值会与记录集数据库中相同时 ...


你增加一个判断就行了 创建了记录集 就可以执行查询 和修改操作
xuanxiao 发表于 2019-7-20 15:01:00 | 显示全部楼层
胡彬 发表于 2019-7-19 09:43
谢谢,十分感谢
这样是能更新数量与单价,我的意思是当我输入的Kuwei字段值会与记录集数据库中相同时 ...




  1. <%
  2. set rs=server.createobject("ADODB.RecordSet")
  3. sql="select * from produit where huohao='"&nowhuohao&"' and id_ku="&nowku
  4. rs.open sql,conn,1,3
  5. if not rs.eof then
  6.                 if   nowkuwei=rs("kuwei") then
  7.                 &#160;&#160;rs("shulian")=rs("shulian")+nowshulian
  8.                 &#160;&#160;rs("price2")=nowpinprice2
  9.       else
  10.             rs.addnew
  11. &#160;&#160;       ' ..........所有新增记录代码
  12. &#160;     &#160;rs("gys")=rs_produit("gys")
  13.          ........               
  14.       end if       
  15.           
  16. rs.update       
  17.          
  18. end if
  19. rs.close
  20. set rs=nothing
  21. %>
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号