Getting data related to what has been selected randomly from a database
-
I have a Questions table in my database where the quuestiions are selected randomly using the following code "public DataTable getQuestion(string concept,string questiontype) {//gives the user the question for the concept selected above string sql = ""; if (concept == "basic") { sql = "SELECT Question FROM Questions WHERE ConceptId LIKE 'BC%'AND QuestionType ='" + questiontype + "' Order by NewId()"; } else if (Concept == "programming") { sql = "SELECT Question FROM Questions WHERE ConceptId LIKE 'PC%'AND QuestionType ='" + questiontype + "'Order by NewId()"; } return dc.load(sql);//dc is an object of data connection class } Another question type is of multiple choice.And for this type of question there's an Options Table which I need to get the options of the question selected randomly using the code above. Any idea how I can do that? Please help.
ML Lingwati
-
I have a Questions table in my database where the quuestiions are selected randomly using the following code "public DataTable getQuestion(string concept,string questiontype) {//gives the user the question for the concept selected above string sql = ""; if (concept == "basic") { sql = "SELECT Question FROM Questions WHERE ConceptId LIKE 'BC%'AND QuestionType ='" + questiontype + "' Order by NewId()"; } else if (Concept == "programming") { sql = "SELECT Question FROM Questions WHERE ConceptId LIKE 'PC%'AND QuestionType ='" + questiontype + "'Order by NewId()"; } return dc.load(sql);//dc is an object of data connection class } Another question type is of multiple choice.And for this type of question there's an Options Table which I need to get the options of the question selected randomly using the code above. Any idea how I can do that? Please help.
ML Lingwati
Good day LucBite Can you explain Briefly what is your Problem. i understand what you are trying to do, but can you tell us what exactly is your problem
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.somee.com http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/
-
Good day LucBite Can you explain Briefly what is your Problem. i understand what you are trying to do, but can you tell us what exactly is your problem
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.somee.com http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
ML Lingwati
-
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
ML Lingwati
Good day LucBite You did Explain Clearly again so that i cannot understand better, remember you showed us a Function that return a datatable, now when i said explain clearly i mean to tell us where does the parameters get passed from(UI or Another Function). I Assume you are trying to do something like this You have a Testing Application, First you have Different type of Test "Basic", "Programming" and "MultipleChoice" Now you can select Randomly for "Basic" and "Programming" But you cannot select Randomly for "MultipleChoice" So you want it to be able to select for "MultipleChoice" Questions Randomly" This is how i understand it ,before i give you a solution , i would like to if am right else explain more give me more info
Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.somee.com http://www.vuyiswamaseko.tiyaneProperties.co.za vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/
-
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
ML Lingwati
-
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
ML Lingwati
So, for a multiple choice question type you want to return random questions and, for each of the questions returned, the applicable options? If I were you, I'd change your sql to return 2 columns for multiple choice, the question text and the id (the primary key on the question table). From there, you can select the options from the appropriate table using the id of the question.
-
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
ML Lingwati
LucBite wrote:
How do I select the options of a multiple choice question, for the multiple choice question that I selected randomly. Remember, I can't select the options randomly because they have to match the question even though the questiion is selected randomly. The questions are from the Questions Table and the options are from the Options Table. I hope I'm clear please help.
I'm not absolutely sure I understand your question, but this is what I think you might be asking for:
class SwitchTest
{
static void Main()
{
Console.WriteLine("Coffee sizes: 1=Small 2=Medium 3=Large");
Console.Write("Please enter your selection: ");
string s = Console.ReadLine();
int n = int.Parse(s);
int cost = 0;
switch(n)
{
case 1:
cost += 25;
break;
case 2:
cost += 25;
goto case 1;
case 3:
cost += 50;
goto case 1;
default:
Console.WriteLine("Invalid selection. Please select 1, 2, or 3.");
break;
}
if (cost != 0)
{
Console.WriteLine("Please insert {0} cents.", cost);
}
Console.WriteLine("Thank you for your business.");
}
}
/*
Sample Input: 2Sample Output: Coffee sizes: 1=Small 2=Medium 3=Large Please enter your selection: 2 Please insert 50 cents. Thank you for your business. \*/
"My interest is in the future because I'm going to spend the rest of my life there." - Charles F. Kettering