Click here to Skip to main content
15,884,821 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i've data on table in one column and want to select one data from table randomly while loading a page on ASP.NET 4.0 C# textbox. how to do it
Posted
Comments
[no name] 11-Aug-12 9:43am    
Try using the Random class.

You didn't mention if you want to do this with a SQL query or in code or something else, but if you want to use SQL and you have SQL Server then one way to select a random row is
SQL
SELECT TOP 1 * FROM YourTable ORDER BY NEWID()
 
Share this answer
 
Comments
Leo Rajendra Dhakal 11-Aug-12 10:18am    
But it's not working on Access Databse
Wendelius 11-Aug-12 10:25am    
So you use Access database. Haven't tried it but you could try something like
SELECT TOP 1 * FROM YourTable ORDER BY RND
[no name] 11-Aug-12 11:23am    
You need to provide all relevant information if you expect good answers to your question. Where in your question did you say you were using am Access database? Or even a database at all?
Thank you Mika, Wendelius, Wes Aday for your good response. It's solved now
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900