conn.asp
<%dim conn
Set conn = Server.CreateObject("ADODB.Connection")
connstr="driver={sql server};server=192.168.1.88;uid=sa;pwd=123;database=master" '数据库连接
conn.open ConnStr
%>
<table border=0 width=98%>
<tr>
<Td wdith=33%><b>position</b></td><Td wdith=33%><b>name </b></td><Td wdith=33%><b><b>telephone </b></td><Td wdith=33%>daytime<b></td><Td wdith=33%><b>nissin</b></td></tr>
<%'读取记录
search=Request.Form("search")
set rs=server.createobject("adodb.recordset")
rs.open "select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN 'daytime1' AND 'daytime2'",conn,1,1
do while not rs.eof
'显示你角色名和等级的排行,有必要你可以根据等级排行来排序
%>
<tr>
<Td width=10%><%=rs("position")%></td><Td width=10%><%=rs("name")%></td><Td width=10%><%=rs("telephone")%></td><Td width=10%><%=rs("daytime")%></td><Td width=60%><%=rs("nissin")%></td></tr>
<%
rs.movenext
loop
rs.close '关闭记录
set rs=nothing
conn.close
%>
</table>
index.asp
<title>日清系统</title>
<style type="text/css">
<!--
.STYLE2 {font-size: large}
-->
</style>
<body>
<table width="780" height="100%" border="0" align="center">
<tr>
<td height="218"><div align="center">
<p class="STYLE2"> </p>
<p class="STYLE2">日清查询系统</p>
</div></td>
</tr>
<tr>
<td><form name="form1" method="post" action="conn.asp">
<p> </p>
<p>
<label></label>
<label></label>
<label></label>
<label>姓名
<input type="text" name="search" value="">
</label>
<label> </label>
<label>开始日期
<input daytime1="daytime1" type="text" id="daytime1" size="10">
</label>
-
<label>结束日期
<input daytime2="daytime2" type="text" id="daytime2" size="10">
</label>
</p>
<p>
<label></label>
<label></label>
<label></label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="查询">
</label>
<label></label>
</p>
</form> </td>
</tr>
</table>
</body>
</html>
我作的ASP读取SQL读不出来,请大家帮忙看下
答案:5 悬赏:70 手机版
解决时间 2021-04-13 20:48
- 提问者网友:浮克旳回音
- 2021-04-13 08:34
最佳答案
- 五星知识达人网友:英雄的欲望
- 2021-04-13 09:42
rs.open "select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN 'daytime1' AND 'daytime2'",conn,1,1
应该是
rs.open "select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN #daytime1# AND #daytime2#",conn,1,1
应该是
rs.open "select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN #daytime1# AND #daytime2#",conn,1,1
全部回答
- 1楼网友:雾月
- 2021-04-13 12:43
你先把 "select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN 'daytime1' AND 'daytime2'",
放在数据库里面试下 在考虑后面的问题
- 2楼网友:几近狂妄
- 2021-04-13 11:42
你好!
select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN 'daytime1' AND 'daytime2'
这句查不出数据
你放到数据查下
仅代表个人观点,不喜勿喷,谢谢。
- 3楼网友:woshuo
- 2021-04-13 10:06
If search="" Or IsNull(search) then
search="给个默认值"
End if
- 4楼网友:低血压的长颈鹿
- 2021-04-13 10:00
select * from [ywrq] where [name] like '%"&search&"%' and [daytime] BETWEEN 'daytime1' AND 'daytime2'
这句查不出数据
你放到数据查下
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯