Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Dreamweaver (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2005, 08:23 AM
Authorized User
 
Join Date: Aug 2005
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Default Randomize value

I have a DataSet that contains products.
On my first page a want to randomize some products.
How would I build the randomize.
I'm using asp.net asp.net don't have the macromedia randomrecord extension.

 
Old September 28th, 2005, 03:43 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If you're using SQL Server, you can do something like:

SELECT TOP 1 Col1, Col2 FROM SomeTable ORDER BY NewId()

The trick here is the NewId function that returns a (semi) random value every time.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Randomize a range frankjuel Excel VBA 5 February 24th, 2016 10:26 AM
Regular Expression for Randomize the sequence srinivasp20 Apache Tomcat 0 July 15th, 2005 02:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.