Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET4.0
Sir,
 
My database is like
--------------------------------
NO            int
Question      vachar(50)
op1           vachar(20)
op2           vachar(20)
op3           vachar(20)
op4           vachar(20)
Ans           vachar(20)
Subjectcode   varchar(20)
----------------------------------
Database has large number of questions of various SubjectCode.
 
I want to fetch some number of question from database based on subjectCode and from this numberof fetched question I want to display random question on to the web-page (one question per page)
 
So I hope you will help me...
 
Thanks a lot....
Posted 21-Sep-12 7:26am
Edited 21-Sep-12 7:35am
Nueman8.1K
v3
Comments
Sandeep Mewara at 21-Sep-12 13:30pm
   
And what is the issue? Did you try anything? Where are you stuck?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can get the select count(*) from tablename of the row in the table, and use the .net Random class.
Random r = new Random();
int i = r.Next(countFromTheTable)+1; // zero based add 1
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Please go through correct answer in Random Questions using DetailsView (Help)[^].

Best Codeproject Articles

1. Online Quiz[^]
2. How to make a random selection from an SQL table[^]
Comments
Tadit Dash at 21-Sep-12 17:09pm
   
Please don't forget to mark this as accepted answer, if it has helped you in any way, so that it will be helpful for others to know the solution easily... You will also be awarded with points for accepting... :) :)
 
Thanks a lot...
Regards,
Tadit

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



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 21 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid