Click here to Skip to main content
12,892,796 members (48,051 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET4

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
Updated 21-Sep-12 7:35am
Sandeep Mewara 21-Sep-12 13:30pm
And what is the issue? Did you try anything? Where are you stuck?
Rate this: bad
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
Rate this: bad
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[^]
Tadit Dash 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...

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100