Solved

How can I assign an ID number to a section of code so that it pulls the appropriate details into the radio list?

Posted on 2004-08-31
10
168 Views
Last Modified: 2010-04-23
The following code pulls a question and assigns it to a label 'lblQ1'

Then ObjCommand.ExecuteReader() pulls in question options from a datasource and assigns them to a radiolist.

lblQ1.Text=(ObjCommand.Parameters("@ReturnQuestion1").Value)

How can I assign an ID number to this section of code so that it pulls the appropriate details into the radio list?
You see, I have a few radiolists one after the other.

Basically, I am trying to pull the appropriate options for each question. At the moment its not matching up the questions with answers.

Sorry, its a difficult problem to explain ....hope this makes some sense.

      RadFSAQ1.DataSource=ObjCommand.ExecuteReader()
      RadFSAQ1.DataTextField="AnswerDescription"
      RadFSAQ1.DataBind()
      objConnection.Close()

Cheers

PG

0
Comment
Question by:pgilfeather
  • 4
  • 3
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
What is the SQL for filling the radio button list?

Bob
0
 

Author Comment

by:pgilfeather
Comment Utility
@QuestionID1 Int,
@QuestionID2 Int,
@QuestionID3 Int,
@QuestionID4 Int,
@QuestionID5 Int,
@QuestionID6 Int,
@QuestionID7 Int,
@QuestionID8 Int,
@QuestionID9 Int,
@QuestionID10 Int,
@QuestionID11 Int,
@QuestionID12 Int,
@QuestionID13 Int,
@QuestionID14 Int,
@QuestionID15 Int,
@QuestionID16 Int,
@QuestionID17 Int,
@QuestionID18 Int,
@QuestionID19 Int,
@QuestionID20 Int,
@ReturnQuestion1 varchar(8000)OUT,
@ReturnQuestion2 varchar(8000)OUT,
@ReturnQuestion3 varchar(8000)OUT,
@ReturnQuestion4 varchar(8000)OUT,
@ReturnQuestion5 varchar(8000)OUT,
@ReturnQuestion6 varchar(8000)OUT,
@ReturnQuestion7 varchar(8000)OUT,
@ReturnQuestion8 varchar(8000)OUT,
@ReturnQuestion9 varchar(8000)OUT,
@ReturnQuestion10 varchar(8000)OUT,
@ReturnQuestion11 varchar(8000)OUT,
@ReturnQuestion12 varchar(8000)OUT,
@ReturnQuestion13 varchar(8000)OUT,
@ReturnQuestion14 varchar(8000)OUT,
@ReturnQuestion15 varchar(8000)OUT,
@ReturnQuestion16 varchar(8000)OUT,
@ReturnQuestion17 varchar(8000)OUT,
@ReturnQuestion18 varchar(8000)OUT,
@ReturnQuestion19 varchar(8000)OUT,
@ReturnQuestion20 varchar(8000)OUT
AS
BEGIN
SET @ReturnQuestion1 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID1 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID1 = QuestionID
END

BEGIN
SET @ReturnQuestion2 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID2 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID2 = QuestionID
END

BEGIN
SET @ReturnQuestion3 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID3 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID3 = QuestionID
END

BEGIN
SET @ReturnQuestion4 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID4 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID4 = QuestionID
END

BEGIN
SET @ReturnQuestion5 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID5 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID5 = QuestionID
END

BEGIN
SET @ReturnQuestion6 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID6 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID6 = QuestionID
END

BEGIN
SET @ReturnQuestion7 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID7 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID7 = QuestionID
END

BEGIN
SET @ReturnQuestion8 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID8 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID8 = QuestionID
END

BEGIN
SET @ReturnQuestion9 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID9 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID9 = QuestionID
END

BEGIN
SET @ReturnQuestion10 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID10 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID10 = QuestionID
END

BEGIN
SET @ReturnQuestion11 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID11 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID11 = QuestionID
END

BEGIN
SET @ReturnQuestion12 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID12 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID12 = QuestionID
END

BEGIN
SET @ReturnQuestion13 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID13 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID13 = QuestionID
END

BEGIN
SET @ReturnQuestion14 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID14 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID14 = QuestionID
END

BEGIN
SET @ReturnQuestion15 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID15 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID15 = QuestionID
END

BEGIN
SET @ReturnQuestion16 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID16 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID16 = QuestionID
END

BEGIN
SET @ReturnQuestion17 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID17 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID17 = QuestionID
END

BEGIN
SET @ReturnQuestion18 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID18 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID18 = QuestionID
END

BEGIN
SET @ReturnQuestion19 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID19 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID19 = QuestionID
END

BEGIN
SET @ReturnQuestion20 = (SELECT Question
                  FROM dbo.tblFSAQuestions
                  WHERE @QuestionID20 = QuestionID)

SELECT AnswerDescription
FROM dbo.tblFSAPossibleAnswers
WHERE @QuestionID20 = QuestionID
END
0
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Could you explain what you are trying to with this?  There are a lot of better ways to accomplish this.  What you have shown is very static, and adding new questions, would only make this more and more complicated.

Bob
0
 

Author Comment

by:pgilfeather
Comment Utility
Right,
here goes.

I have a quiz that randomly pulls questions from a datasource via the QuestionID number.

The ID Numbers are pulled into an array before being fed into the parameters that pull the data.

I want to pull 20 Questions onto a web page via these array id numbers but at the moment the questions are not matching up with the multichoice options.

Hope this helps

Regards

PG

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Are the questions and the options in separate tables?  How are they related?

Bob
0
 

Author Comment

by:pgilfeather
Comment Utility
They are in separate tables linked by the QuestionID

The columns I want to pull are

Question (from table 1)-----Which sets the question

QuestionOptions(from table 2) ----Which sets the multichoice options

0
 

Author Comment

by:pgilfeather
Comment Utility
1Question = many QuestionOptions

so 1 to many relationship
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
Comment Utility
use a dataadapter to fill two tables in a dataset then setup the relation between the two on the question id ... then you can just use GetChildRows() to get the multiple choice answers for a given question ...

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now