我想写一段代码,效果如下: 如果找到相同的出货单号码,则更新该出货单的内容,如果找不到该出货单,则增加一条出货单记录.
基本代码入下,具体要怎么修改?
<%
set rs=server.CreateObject( "adodb.recordset ")
rs.Open "select * from huokuan where chuhuodan= "&request( "chudanhao "),conn,1,3
if rs.eof then
rs.AddNew
rs( "chuhuodan ")=request( "chudanhao ")
rs( "company ")=trim(request( "company "))
rs( "tel ")=trim(request( "tel "))
rs.Update
end if
rs.Close
set rs=nothing
%>
------解决方案--------------------
如果request( "chudanhao ")的值是数字的话
rs.Open "select * from huokuan where chuhuodan= "&request( "chudanhao "),conn,2,3
字符串的话
rs.Open "select * from huokuan where chuhuodan= ' "&request( "chudanhao ") & " ' ",conn,2,3