asp模糊查询代码
具体是这样:这是我查询的表<tablecellpadding="2"cellspacing="1"border="0"width="680"align="center"c...
具体是这样:这是我查询的表
<table cellpadding="2" cellspacing="1" border="0" width="680" align="center" class="a2">
<tr>
<td class="a1" height="25" align="center"><strong>查询出租车司机登记数据</strong></td>
</tr>
<tr>
<td align="center">
<FORM language=javascript method=post action="chaxun2.asp">
<table width="720" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td width="60" height="25" bgcolor="#ffffff"><div align="center">车主姓名:</div></td>
<td><input name="usernames" type="usernames" size="20" maxlength="20"></td>
<td width="60" height="25" bgcolor="#ffffff"><div align="center">车牌号:</div></td>
<td><input name="chepaihao" type="chepaihao" size="20" maxlength="20"></td>
</tr>
<tr>
<td height="22" colspan="6"><div align="center"><INPUT type=submit value='查询'name=Submit></div></td>
</tr>
</table>
</form> </td>
</tr>
实现代码是这么写的:
set rs1=server.createobject("adodb.recordset")
sqltext="select * from datas where usernames="& trim(request("username"))
rs1.open sqltext,conn,3,3 展开
<table cellpadding="2" cellspacing="1" border="0" width="680" align="center" class="a2">
<tr>
<td class="a1" height="25" align="center"><strong>查询出租车司机登记数据</strong></td>
</tr>
<tr>
<td align="center">
<FORM language=javascript method=post action="chaxun2.asp">
<table width="720" border="0" align="center" cellpadding="0" cellspacing="2">
<tr>
<td width="60" height="25" bgcolor="#ffffff"><div align="center">车主姓名:</div></td>
<td><input name="usernames" type="usernames" size="20" maxlength="20"></td>
<td width="60" height="25" bgcolor="#ffffff"><div align="center">车牌号:</div></td>
<td><input name="chepaihao" type="chepaihao" size="20" maxlength="20"></td>
</tr>
<tr>
<td height="22" colspan="6"><div align="center"><INPUT type=submit value='查询'name=Submit></div></td>
</tr>
</table>
</form> </td>
</tr>
实现代码是这么写的:
set rs1=server.createobject("adodb.recordset")
sqltext="select * from datas where usernames="& trim(request("username"))
rs1.open sqltext,conn,3,3 展开
展开全部
用%号匹配 注意写sql语句时字符应该用单引号括起来
sqltext="select * from datas where usernames like %'"& trim(request("username"))&"%'"
sqltext="select * from datas where usernames like %'"& trim(request("username"))&"%'"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sqltext="select * from datas where usernames like '%" & trim(request('username')) & "%'"
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sqltext="select * from datas where usernames like %"& trim(request("username"))%
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询