我想 如果库里存在 那么就更新已有库存
如果库里不存在 则添加新纪录
但是这样写 总是执行IF后面 语句 我把rs.addnew 放在前面
它就执行rs.addnew 始终不作判断哦
有大虾指点为:
if not rs.eof then
rs("now_name")=request("now_name")
.
.
.
rs.update
else
rs.addnew
rs("now_name")=request("now_name")
.
.
.
rs.update
end if
看看我改的对不
但是还是不行 郁闷
<!--#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 not rs.eof then
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("now_amount")
rs("unit")=request("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")=request("now_manager")
rs.update
rs.close
conn.close
set rs=nothing
response.write "<script language='javascript'>" & chr(13)
response.write "alert('asdf 功!');" & Chr(13)
response.write "window.document.location.href='nowmaterial_manage.asp';"&Chr(13)
response.write "</script>" & Chr(13)
Response.End
else
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%>