关于ASP的判断语句
当输入的信息与数据库里的一致时,则number项与输入的use_num项相加,否然另起一行记录。为什么我下面的这段代码不能实现我想要的功能?<%setrs1=server...
当输入的信息与数据库里的一致时,则number项与输入的use_num项相加,否然另起一行记录。为什么我下面的这段代码不能实现我想要的功能?
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from store where class='"&trim(request("d_position1"))&"' and nun='"&trim(request("nun"))&"' and pinming='"&trim(request("pinming"))&"' and guige='"&trim(request("guige"))&"' and Unit='"&trim(request("Unit"))&"'"
rs.open sql,conn,1,3
if not rs1.eof then
rs1("number")=rs1("number")+request("use_num")
rs1("price") = request("use_price")
else
rs1.addnew
......
%>
<%
set rs1=server.createobject("adodb.recordset")
rs1.open sql1,conn,1,3
sql1="select * from store where class='"&trim(request("d_position1"))&"' and nun='"&trim(request("nun"))&"' and
pinming='"&trim(request("pinming"))&"' and guige='"&trim(request("guige"))&"' and Unit='"&trim(request("Unit"))&"'"
if not rs1.eof then
rs1("number") = rs1("number") + request("use_num")
rs1("price") = request("price")
else
rs1.addnew
rs1("class") = request("d_position1")
rs1("nun") = request("nun")
rs1("pinming") = request("pinming")
rs1("guige") = request("guige")
rs1("price") = request("price")
rs1("Unit") = request("Unit")
rs1("number") = request("use_num")
rs1.update
rs1.close
end if
set rs1=nothing
%>
请问,这样为什么不能写入 展开
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from store where class='"&trim(request("d_position1"))&"' and nun='"&trim(request("nun"))&"' and pinming='"&trim(request("pinming"))&"' and guige='"&trim(request("guige"))&"' and Unit='"&trim(request("Unit"))&"'"
rs.open sql,conn,1,3
if not rs1.eof then
rs1("number")=rs1("number")+request("use_num")
rs1("price") = request("use_price")
else
rs1.addnew
......
%>
<%
set rs1=server.createobject("adodb.recordset")
rs1.open sql1,conn,1,3
sql1="select * from store where class='"&trim(request("d_position1"))&"' and nun='"&trim(request("nun"))&"' and
pinming='"&trim(request("pinming"))&"' and guige='"&trim(request("guige"))&"' and Unit='"&trim(request("Unit"))&"'"
if not rs1.eof then
rs1("number") = rs1("number") + request("use_num")
rs1("price") = request("price")
else
rs1.addnew
rs1("class") = request("d_position1")
rs1("nun") = request("nun")
rs1("pinming") = request("pinming")
rs1("guige") = request("guige")
rs1("price") = request("price")
rs1("Unit") = request("Unit")
rs1("number") = request("use_num")
rs1.update
rs1.close
end if
set rs1=nothing
%>
请问,这样为什么不能写入 展开
展开全部
if not rs.eof then
sql="update store set number=number+"&request("use_num")&",price="&request("use_price")&" where class='"&trim(request("d_position1"))&"' and nun='"&trim(request("nun"))&"' and pinming='"&trim(request("pinming"))&"' and guige='"&trim(request("guige"))&"' and Unit='"&trim(request("Unit"))&"'"
conn.execute(sql)
else
sql=" insert into store (…,…,…,…) values (…,…,…,…)"//具体有哪些字段自己看着加
conn.execute(sql)
end if
……
rs.close
sql="update store set number=number+"&request("use_num")&",price="&request("use_price")&" where class='"&trim(request("d_position1"))&"' and nun='"&trim(request("nun"))&"' and pinming='"&trim(request("pinming"))&"' and guige='"&trim(request("guige"))&"' and Unit='"&trim(request("Unit"))&"'"
conn.execute(sql)
else
sql=" insert into store (…,…,…,…) values (…,…,…,…)"//具体有哪些字段自己看着加
conn.execute(sql)
end if
……
rs.close
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询