asp 数据查询两种方式的总结

来源:互联网 发布:微博可以推广淘宝店铺 编辑:程序博客网 时间:2024/05/16 17:52

第一种:
 '使用数据库连接对象查询数据集对象,用 set变量接收。
 set rset1 = conn.execute("select * from productType where id="&request("id"))
 
 '表示只能取出结果集里面的值,但是不能取到总的条数之类的。。。
 set rset2 = conn.execute("select top 8 * from productType where typeId="&request("id")&" order by id")


第二种:
 '表示的是可以取结果集、可以取到总的条数,比如分页
 'set rset2=server.createobject("adodb.recordset")  =========创建一个可以用于分页等功能的结果集对象。包含有一些属性和方法
 'rset2.open "select top 8 * from productType where typeId="&request("id")&" order by id",conn,1,1 ====调用这个结果集对象执行open方法,使用数据库连接查询数据,并返回一个封装好的结果对象。

原创粉丝点击