asp中读取access数据库数据的问题

来源:百度知道 编辑:UC知道 时间:2024/05/08 05:08:06
如何使用asp将access数据库中某条特定数据读出来呢?

例如access数据库的结构为:
表1
里面有 字段1、字段2、字段3

字段1为一级分类,字段2为二级分类,字段3为三级分类
想读出字段1=a,字段2=b,字段3为空

a为一级分类,b二级分类,c三级分类
b为a下的分类,c为b下的分类
读出b分类的新闻,但属于c分类的新闻不被读出

我的查询语句是这样的,但什么都读不出
sql="select * from news where BigClassName='"&owen1&"' and SmallClassName='"&owen2&"' and threeclassname='""' order by id desc"

多谢各位~~~
连接了
把and threeclassname='""'取了,就正常了,但是把它下面的三级分类的新闻也读出来了
西奈山的摩西::我的是access数据库
wangsdong::我都试过了,什么都读不出了

threeclassname='""'
这个改成
threeclassname=''
试试

打印一下该SQL语句,放到查询分析器里验证下,就知道问题了

sql="select * from news where BigClassName='"&owen1&"' and SmallClassName='"&owen2&"' and threeclassname='""' order by id desc"

response.write(sql)
response.end();

你连接数据库了吗?
<% set conn= Server.CreateObject("adodb.connection")
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("db1.mdb")
conn.open connstr
%>