Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Select a random record in sql
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

redbrad0
Advanced Member

USA
3725 Posts

Posted - 19 April 2001 :  16:09:55  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
im looking for this now, just seeing if anyone knows a quick way.

I have a table with ID fields for each entry, and i need to get a random record from the table. The ID numbers are not in order, some items get deleted. Can anyone help?

Brad

redbrad0
Advanced Member

USA
3725 Posts

Posted - 19 April 2001 :  16:58:50  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Just incase anyone else would like to know....


strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.MEMBER_ID FROM " & strMemberTablePrefix & "MEMBERS"
set rs = Server.CreateObject("ADODB.Recordset")
rs.cachesize = "1"
rs.open strSql, my_Conn, 3

if not(rs.EOF or rs.BOF) then '## Images found in DB
rs.movefirst
strMembersInDB = cint(rs.RecordCount)
Randomize Timer
RndMemberNumber = Int(Rnd * strMembersInDB)
rs.move cint(RndMemberNumber)
end if


THIS CODE IS NOT FOR SNITZ FORUM'S IT COULD BE USED, BUT IM NOT SURE IF THE TABLE NAMES ARE CORRECT

Brad
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.24 seconds. Powered By: Snitz Forums 2000 Version 3.4.07