I am really new to Visusal Studio / C# / ASP.
But currently i am doing a little test project, to make a website, with a quiz, where users can go in and fill out information.
I've made the backend, to insert new questions/Answers etc.
My databases is as following:
My databases is as following:
Questions: ( the tabel for the questions name)
- Questionsid
- QuestionsName
QuizAnswers ( the tabel for all the differently answers, to each question, that a Administrator create) )
- QuizAnswerID
- QuestionsID
- QuizAnswer
- Correct (True/False)
But my big problem is this.
I am used to Dreamweaver and php.
I need to show all the Questions from Questions tabel, and include the answers below the questions.
The key to combine the 2 tabels are the: "QuestionsID".
I've searched all of google, with no real results, and right now i am lost...
So my problem is:
1. How do i display the questions and the answers, and at the same time to combine the 2 tabels, with the QuestionsId.
2. How do i repeat that, so that i can repeat the region, until the questions tabel is empty, like if i want to show 10 questions, and all the answers to each question.
So my problem is:
1. How do i display the questions and the answers, and at the same time to combine the 2 tabels, with the QuestionsId.
2. How do i repeat that, so that i can repeat the region, until the questions tabel is empty, like if i want to show 10 questions, and all the answers to each question.
Ex:
What color is bla bla: (Question name is from the Question tabel)
What color is bla bla: (Question name is from the Question tabel)
1 - Red (The answer is from the Answers tabel)
2- Blue (The answer is from the Answers tabel)
2- Blue (The answer is from the Answers tabel)
Regards
Matias
Matias
Matias aabyePosted May 11, 2013, 10:33 PM
In CS PAGE:
On main page:
boycotoPosted May 9, 2013, 11:29 PM
{
DataTable dt = new DataTable();
//Declare your connection obj
SqlConnection connObject = new SqlConnection();
//Declare you command object
SqlCommand cmdObject = new SqlCommand();
//Assign connection to your connection
cmdObject.Connection = connObject;
//Use ExecuteReader to retrieve records
cmdObject.CommandText = "SELECT Table1.QuestionName, Table2.QuizAnswer1, Table2.QuizAnswer2, Table2.QuizAnswer3, Table2.QuizAnswer4 FROM Table1 INNER JOIN Table2 ON Table1.QuestionId=Table2.QuestionId";
SqlDataAdapter ad = new SqlDataAdapter();
ad.Fill(dt);
Response.Write("
foreach (DataRow dr in dt.Rows)
{
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
Response.Write("
}
Response.Write("
dt.Dispose();
ad.Dispose();
cmdObject.Dispose();
connObject.Close();
}
Matias aabyePosted May 9, 2013, 10:28 PM
boycotoPosted May 9, 2013, 10:13 PM
Matias aabyePosted May 9, 2013, 10:09 PM
boycotoPosted May 9, 2013, 9:41 PM
Response.Write("
For Each DataRow in DataTable
End For
Response.Write("