vb6 rs记录集,怎么取其中的一段记录

ningweidong 2011-05-19 02:41:41
我用rs查询数据库,比如说,返回了100条记录。我该怎样取其中某一段的记录?比如,第10至20条记录?只有用rs.movenext循环到第10条记录吗?没有其它方法?
...全文
358 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxq19851204 2011-05-19
  • 打赏
  • 举报
回复
猴哥给力!!
chinaboyzyq 2011-05-19
  • 打赏
  • 举报
回复
可以使用AbsolutePage、PageCount 和 PageSize 属性来划分页。

该范例使用 AbsolutePage、PageCount 和 PageSize 属性,以每次五个记录的方式显示雇员表中的姓名和受雇日期。

Public Sub AbsolutePageX()

Dim rstEmployees As ADODB.Recordset
Dim strCnn As String
Dim strMessage As String
Dim intPage As Integer
Dim intPageCount As Integer
Dim intRecord As Integer

' 使用客户端游标为雇员表打开一个记录集。
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "
Set rstEmployees = New ADODB.Recordset
' 使用客户端游标激活 AbsolutePosition 属性。
rstEmployees.CursorLocation = adUseClient
rstEmployees.Open "employee", strCnn, , , adCmdTable

' 显示姓名和受雇日期,每次五个记录。
rstEmployees.PageSize = 5
intPageCount = rstEmployees.PageCount
For intPage = 1 To intPageCount
rstEmployees.AbsolutePage = intPage
strMessage = ""
For intRecord = 1 To rstEmployees.PageSize
strMessage = strMessage & _
rstEmployees!fname & " " & _
rstEmployees!lname & " " & _
rstEmployees!hire_date & vbCr
rstEmployees.MoveNext
If rstEmployees.EOF Then Exit For
Next intRecord
MsgBox strMessage
Next intPage
rstEmployees.Close

End Sub

----------------------------
也可以先
rs.move 10,1
然后再用rs.movenext一条一条取到第20条。
lxq19851204 2011-05-19
  • 打赏
  • 举报
回复
MSSQL用TOP返回
MYSQL用LIMIT返回
jxjdzwang5555 2011-05-19
  • 打赏
  • 举报
回复
sele * from table where recno() between 10 and 20
vbman2003 2011-05-19
  • 打赏
  • 举报
回复
move方法...
饮水需思源 2011-05-19
  • 打赏
  • 举报
回复
rs查询就加入查询条件

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧