Windsailor
Well-known member
- Joined
- Aug 2, 2006
- Messages
- 45
- Programming Experience
- 1-3
To set the stage, Tables are set up as such for this question:
-----------
Table: Answers
ID - Integer - Auto
Answer - Integer
QuestionID - Integer - FK from the QuizMaster table
StudentID - Integer - FK from the Students table
Table: QuizMaster
ID - Integer - Auto
Answer - Integer
Table: Students
ID - Integer - Auto
StudentName - Varchar(50)
----------
The SQL statement is:
Which works great... returning the correct results.
But... I am having difficulty in binding a datagrid to show all of the results of the SQL statement... or you might say difficulty in creating a correct datasource for my datagrid.
I originally used an adapter that was (SELECT Answer FROM Answers) and then re-configured it with the above statement.
In the preview of the adapter I show the fields...
Answer, StudentName, TotalCorrect, TotalQuestions, PercentValue: with the correct values listed in them (The 'Answer' column being blank and the rest filled in).
But in the designer.vb portion of the dataset, only the 'Answer' column attributes are listed... and the rest of the custom columns do not exist.
Do I have to go in and manually create the attributes for those custom columns?
How else would I do this?
-----------
Table: Answers
ID - Integer - Auto
Answer - Integer
QuestionID - Integer - FK from the QuizMaster table
StudentID - Integer - FK from the Students table
Table: QuizMaster
ID - Integer - Auto
Answer - Integer
Table: Students
ID - Integer - Auto
StudentName - Varchar(50)
----------
The SQL statement is:
VB.NET:
SELECT
StudentName,
TotalCorrect,
TotalQuestions,
CAST(([TotalCorrect])/([TotalQuestions])*100 as numeric(5,2)) AS PercentValue
FROM (
SELECT Students.StudentName,
CAST(COUNT(Students.StudentName) AS numeric(5, 2)) AS TotalCorrect,
CAST((SELECT COUNT(QuizMaster.ID) FROM QuizMaster) AS numeric(5, 2)) AS TotalQuestions
FROM (Answers
INNER JOIN Students
ON Answers.StudentID = Students.ID)
INNER JOIN QuizMaster
ON (Answers.Answer = QuizMaster.Answer)
AND (Answers.QuestionID = QuizMaster.ID)
GROUP BY Students.StudentName
) t
ORDER BY StudentName, PercentValue DESC
Which works great... returning the correct results.
But... I am having difficulty in binding a datagrid to show all of the results of the SQL statement... or you might say difficulty in creating a correct datasource for my datagrid.
I originally used an adapter that was (SELECT Answer FROM Answers) and then re-configured it with the above statement.
In the preview of the adapter I show the fields...
Answer, StudentName, TotalCorrect, TotalQuestions, PercentValue: with the correct values listed in them (The 'Answer' column being blank and the rest filled in).
But in the designer.vb portion of the dataset, only the 'Answer' column attributes are listed... and the rest of the custom columns do not exist.
Do I have to go in and manually create the attributes for those custom columns?
How else would I do this?