asp 条件查询代码怎么写
代码如下,但现在想根据location的值来确定搜索的项目,如果location的值为101那就搜索显示materialnomaterialdesc,location的值...
代码如下,但现在想根据location的值来 确定搜索的项目,如果location的值为101 那就搜索显示materialno materialdesc,location的值,如果location的值为102则显示materialno,materialdesc,location,uername的值 如果location的值不是101也不是102 则系统提示"不存在的搜索条件" 高手帮忙了谢谢!
<%
set conn=server.createobject("adodb.connection"
conn.Open"provider=Microsoft.jet.oledb.4.0;data source="&Server.MapPath("master.mdb")
materialno=request.form("materialno")
materialdesc=request.form("materialdesc")
location=request.form("location")
username=request.form("username")
department=request.form("department")
exec="select * from material where materialno='"+materialno+"' or location='"+location+"'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
<html>
<head>
<title>在库查询系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%>
<table>
<tr>
<td><%=rs("materialno")%></td>
<td><%=rs("materialdesc")%></td>
<td><%=rs("location")%></td>
<td><%=rs("username")%></td>
<td><%=rs("department")%></td>
</tr>
</table>
<%
rs.movenext
loop
%>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%> 展开
<%
set conn=server.createobject("adodb.connection"
conn.Open"provider=Microsoft.jet.oledb.4.0;data source="&Server.MapPath("master.mdb")
materialno=request.form("materialno")
materialdesc=request.form("materialdesc")
location=request.form("location")
username=request.form("username")
department=request.form("department")
exec="select * from material where materialno='"+materialno+"' or location='"+location+"'"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1
%>
<html>
<head>
<title>在库查询系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
do while not rs.eof
%>
<table>
<tr>
<td><%=rs("materialno")%></td>
<td><%=rs("materialdesc")%></td>
<td><%=rs("location")%></td>
<td><%=rs("username")%></td>
<td><%=rs("department")%></td>
</tr>
</table>
<%
rs.movenext
loop
%>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询