请各位大虾帮忙看看
我想实现:查询数据库 如果有那么就将数据库的内容 部分字段更新
如果没有 就追加一条新纪录
而
为什么 每次运行只运行前半段 而不进行判断呢?
<!--#INCLUDE FILE="data1.asp" -->
<!--#INCLUDE FILE="html.asp" -->
<%
temp1=request("now_name")
set rs=server.CreateObject("adodb.recordset")
sql="selcet * from nowmaterial where now_name='"&temp1&"'"
rs.open sql,conn,1,3
if rs.recordcount>1 then
rs("now_name")=rs("now_name")
rs("type")=rs("type")
rs("now_spec")=rs("now_spec")
rs("now_model")=rs("now_model")
rs("now_amount")=request("now_amount")+rs("now_amount")
rs("unit")=rs("unit")
rs("now_price")=request("now_price")
rs("now_total")=request("now_price")*(request("now_amount")+rs("now_amount"))
rs("now_beizhu")=Server.HTMLEncode(request.Form("now_beizhu"))
rs("now_lbuyer")=request("now_lbuyer")
rs("last_indate")=request("last_indate")
rs("add")=request("add")
rs("now_manager")=rs("now_manager")
rs.update
rs.close
conn.close
set rs=nothing
response.write "<script language='javascript'>" & chr(13)
response.write "alert('库存更新成 功!');" & Chr(13)
response.write "window.document.location.href='nowmaterial_manage.asp';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
else
set rs=server.CreateObject("adodb.recordset")
sql="select * from nowmaterial"
rs.open sql,conn,1,3
rs.addnew
rs("now_name")=request("now_name")
rs("type")=request("type")
rs("now_spec")=request("now_spec")
rs("now_model")=request("now_model")
rs("now_amount")=request("now_amount")
rs("unit")=request("unit")
rs("now_price")=request("now_price")
rs("now_total")=request("now_amount")*request("now_price")
rs("now_beizhu")=Server.HTMLEncode(request.Form("now_beizhu"))
rs("now_lbuyer")=request("now_lbuyer")
rs("last_indate")=request("last_indate")
rs("add")=request("add")
rs("now_manager")=request("now_manager")
rs.update
rs.close
conn.close
set rs=nothing
response.write "<script language='javascript'>" & chr(13)
response.write "alert('该物资入库登记成功!');" & Chr(13)
response.write "window.document.location.href='nowmaterial_manage.asp';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
%>
<%end if%>