手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp下实现记录集内随机取记录的代码
asp下实现记录集内随机取记录的代码
摘要:记录集内随机取记录的代码0)Then记录集名称.MoveFirstElse记录集名称.RequeryEndIfEndIf'nowdofina...

记录集内随机取记录的代码

<%

'Movingtorandomrecord-StevenJones'Extension

IfNot(记录集名称.bofand记录集名称.eof)Then

'resetthecursortothebeginning

If(记录集名称.CursorType>0)Then

记录集名称.MoveFirst

Else

记录集名称.Requery

EndIf

记录集名称_totalrn=-1

记录集名称_totalrn=记录集名称.RecordCount'onyworksonsomerecordsets,butmuchfaster

If(记录集名称_totalrn=-1)Then'andifitdidn'twork,westillhavetocounttherecords.

'countthetotalrecordsbyiteratingthroughtherecordset

记录集名称_totalrn=0

While(Not记录集名称.EOF)

记录集名称_totalrn=记录集名称_totalrn+1

记录集名称.MoveNext

Wend

'resetthecursortothebeginning

If(记录集名称.CursorType>0)Then

记录集名称.MoveFirst

Else

记录集名称.Requery

EndIf

EndIf

'nowdofinaladjustments,andmovetotherandomrecord

记录集名称_totalrn=记录集名称_totalrn-1

If记录集名称_totalrn>0Then

Randomize

记录集名称.MoveInt((记录集名称_totalrn+1)*Rnd)

EndIf

EndIf

'alldone;youshouldalwayscheckforanemptyrecordsetbeforedisplayingdata

%>

【asp下实现记录集内随机取记录的代码】相关文章:

asp完整登陆代码

ASP代码实现301重定向及带参数的方法

asp 全面安全数据连接代码

asp实现的7xi音乐网的采集源代码

asp中创建多级目录的两段代码

ASP实现头像图像随机变换

在ASP中用组件检测当前网卡地址的代码

Asp遍历服务器对象的代码

用asp实现的数据库中存取文件的代码

asp 获取地址栏参数代码

精品推荐
分类导航