★asp★ 得到记录集后 能否在记录集中查询!100

来源:百度知道 编辑:UC知道 时间:2024/06/22 05:36:00
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_zhengzhan_STRING
Recordset1_cmd.CommandText = "SELECT * FROM 新闻分类"
Recordset1_cmd.Prepared = true
-------------------------------------------------
* 以上代码没有任何问题。不需要修改。

问题1:
查询后需要分3次显示,不是一次都显示出来。
比如有(分类)字段。
字段=1 的先显示
再显示分类=2的信息
再显示分类=3的数据
---------------------------------------------------
主要问题 即 查询数据库一次后能否 对查询结果按条件显示
-----------------
这种解决方法不需要
--------------------
查询第一次 条件 分类=1
if 不到末尾
循环显示
查询第二次 条件 分类=2 and 属于当前分类
if 不到末尾
循环显示
查询第三次 条件 分类=3 and 属于当前分类
if 不到末尾
循环显示
end if
end if
end if
---------就为得到一个列表 查了3遍 效率太低---------
----以下为数据库内容------
id 级别 名称 索引id
1 1 在线阅读 0
4 2 阅读科幻 1
11 3 科幻小说1 4
12 3 科幻小说2 4
13 3 科幻小说3 4
5 2 阅读言情 1

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_zhengzhan_STRING
Recordset1_cmd.CommandText = "SELECT * FROM 新闻分类 order by 分类 desc"
Recordset1_cmd.Prepared = true

RS从BOF列到EOF
定义一个数组
存放符合条件的记录
可以用|串起来
使用时再用SPLIT分开了即可.
a[i]="A|B|C"
do while not eof()
if 条件1 then
a[i]=a[i]&rs("XXXX")&"|"
end if
if 条件1 then
a[i]=a[i]&rs("XXXXYYYY")&"|"
end if
rs.movenext
loop
循环一遍就可以了