请问如何随机地从数据库中抽取十条记录(有分)

ccyylib 2003-08-30 12:49:00
并把该十条记录在datagrid中显示出来.
...全文
73 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
kinmax 2003-08-30
  • 打赏
  • 举报
回复
ssql="select top 10 from 表1" 选取表1中前十条记录。
set rs=cn.openrecordset(ssql,rdopenstatic,rdconcurreadonly)
if not rs.eof then
with me.datagrid
.clesr
.rows=rs.rowcount+2
end with
for i=0 to rs.rowcount-1
with me.datagrid
.textgrid(i+1,0)=rs!字段1
.textgrid(i+1,0)=rs!字段2
.textgrid(i+1,0)=rs!字段3
.textgrid(i+1,0)=rs!字段4
。。。。。
end with
rs.monext
next i
endif

据我所知,随机取数据光用SQL语句可能无法实现。

1,216

社区成员

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

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