我想做一个多条件查询asp界面,但是查询后没有结果,也没有报错,求高手解答
时间:2011-08-20
来源:互联网
分为2个页面,一个输入页面search.asp,一个显示页面select2.asp,还一个连接页面conn.asp。
search.asp页面
<!--#include file="conn.asp"--><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>管理系统</title>
</head>
<html>
<body>
<form method="post" action="select2.asp">
<pre>
<font size="2">ID:</font>
<input type="text" name="name" size="10" />
<font size="2">状态: </font>
<select name="zhuangtai">
<option value="选择">选择</option>
<option value="入">入</option>
<option value="出">出</option>
</select>
地点:
<select name="didian">
<option value="选择">选择</option>
<option value="仓库">仓库</option>
<option value="采购部">采购部</option>
</select>
<input type="submit" name="btn_seek" value="搜索">
<input type="reset" name="btn_cancel" value="取消">
<input type="submit" name="btn_browse" value="浏览">
</font> </pre>
</form>
select2.asp页面
<!--#include file="conn.asp"--><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>管理系统</title>
</head>
<html>
<body>
<html>
<%
if request("btn_seek")<> empty then
ID=trim(request("name"))
ad=trim(request("didian"))
status=trim(request("zhuangtai"))
if ID="" and ad="选择" and status="选择" then
response.write "您没有输入查询条件!<br /> <br />"
response.write "请输入条件后查询!<br /><br />"
response.write "</font></h2> "
response.write "<input type=""button"" name=""btn_goback"" value=""返回"" /> "
response.write"</center>"
response.end
end if
sql_text="select * from card2 where 1=1"
if ID="" then
sql_text=sql_text
else
sql_name="and ID ='"&ID&"'" '如果列名ID是字符类型属性加单引号“'”,如果是序列号或数字类型不加
end if
sql_text=""&sql_text&""&sql_name
if ad="选择" then
sql_text=sql_text
else
sql_xueli=" and ad='"&ad&"'"
end if
sql_text=""&sql_text&""&sql_xueli
if status="选择" then
sql_text=sql_text
else
sql_zhicheng=" and status='"&status&"'"
end if
sql_text=""&sql_text&""&sql_zhicheng
sql_text=""&sql_text&" order by time desc"
else
sql_text="select * from card2 order by time desc"
end if
%>
conn.asp页面
<%
dim conn,rs,sql
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/data.mdb")
set rs=server.createobject("adodb.recordset")
%>
数据表card2,里面的字段有ID,ad,time(自动获取时间),status;ID,ad,status都是文本型字段
search.asp页面
<!--#include file="conn.asp"--><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>管理系统</title>
</head>
<html>
<body>
<form method="post" action="select2.asp">
<pre>
<font size="2">ID:</font>
<input type="text" name="name" size="10" />
<font size="2">状态: </font>
<select name="zhuangtai">
<option value="选择">选择</option>
<option value="入">入</option>
<option value="出">出</option>
</select>
地点:
<select name="didian">
<option value="选择">选择</option>
<option value="仓库">仓库</option>
<option value="采购部">采购部</option>
</select>
<input type="submit" name="btn_seek" value="搜索">
<input type="reset" name="btn_cancel" value="取消">
<input type="submit" name="btn_browse" value="浏览">
</font> </pre>
</form>
select2.asp页面
<!--#include file="conn.asp"--><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>管理系统</title>
</head>
<html>
<body>
<html>
<%
if request("btn_seek")<> empty then
ID=trim(request("name"))
ad=trim(request("didian"))
status=trim(request("zhuangtai"))
if ID="" and ad="选择" and status="选择" then
response.write "您没有输入查询条件!<br /> <br />"
response.write "请输入条件后查询!<br /><br />"
response.write "</font></h2> "
response.write "<input type=""button"" name=""btn_goback"" value=""返回"" /> "
response.write"</center>"
response.end
end if
sql_text="select * from card2 where 1=1"
if ID="" then
sql_text=sql_text
else
sql_name="and ID ='"&ID&"'" '如果列名ID是字符类型属性加单引号“'”,如果是序列号或数字类型不加
end if
sql_text=""&sql_text&""&sql_name
if ad="选择" then
sql_text=sql_text
else
sql_xueli=" and ad='"&ad&"'"
end if
sql_text=""&sql_text&""&sql_xueli
if status="选择" then
sql_text=sql_text
else
sql_zhicheng=" and status='"&status&"'"
end if
sql_text=""&sql_text&""&sql_zhicheng
sql_text=""&sql_text&" order by time desc"
else
sql_text="select * from card2 order by time desc"
end if
%>
conn.asp页面
<%
dim conn,rs,sql
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/data.mdb")
set rs=server.createobject("adodb.recordset")
%>
数据表card2,里面的字段有ID,ad,time(自动获取时间),status;ID,ad,status都是文本型字段
作者: szy1910 发布时间: 2011-08-20
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/data.mdb")
------------->>>
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/data.mdb")&"
另外,建议你把你的字段都加上[ ]
------------->>>
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database/data.mdb")&"
另外,建议你把你的字段都加上[ ]
作者: satherose 发布时间: 2011-08-20
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28