asp查询数据库特定语句

来源:百度知道 编辑:UC知道 时间:2024/06/05 17:29:48
我的代码是
set rs = server.CreateObject("ADODB.recordset")
sql = "select * from [content] where hot=2 order by id desc"
rs.open sql,conn,1,1
但是老显示第三行出错
是怎么回事啊?
第二个问题
sql的搜索语句是多少,我忘记了,
sql = "select * from [content] where like name="*龙*" order by id desc "
这样正确吗?而且"?龙*"和"*龙*",第一个的?和*哪个是代表第一个字符....
!--#include file="conn.asp" -->
<%
set rs = server.CreateObject("ADODB.recordset")
sql = "select * from [content] where hot=1" '读取名为content的表
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write "没有信息"
else%>
<title>产品列表【最新】</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
.STYLE1 {font-size: 16px}
-->
</style>
<% do while not rs.eof %>
<table width="60

1、你检查一下看看conn是不是已经打开了。如果打开了,你把错误代码贴出来。

2、不要用like name="*龙*" 要用 name like '*龙*'

?匹配一个字符
*匹配n个字符

--------------------------------------------------------------------
看看数据库,hot字段什么类型,估计是字符型,那么不能那样写:

sql = "select * from [content] where hot='1'"