mmalik15
asked on
Insert into one to many relationship
I want to create an asp page for one to many relationship. I have questions in one table and possible answers in other table. Now when i add a new question at the same time i have to add the possible answers. I managed to add a new question using a form and after its added; a button click takes to a new page to add answers. What the best way to add possible asnwers ? How shall i display my form and which control will be good for it ? (Also a question might have 2 to 5 possible Answers) My possibleAnswer table has three fields QuestionID,PossibleAnswer, CorrectAns wer
using VS2005 with VB.net & SQL server 2005
Thanks in advance
using VS2005 with VB.net & SQL server 2005
Thanks in advance
ASKER
Thanks for your comment. I will try to explain it bit more.
I have two tables Question(QuestionID,Questi onDesc, NoOfPossibleAnswers,Status ) and QuestionPossibleAnswers(Qu estionID,P ossibleAns wer,Answer s). A parent form where i add a question (which i manage to add) and now i have to add the Question possible answers (which can be many). Now how the child form can be designed by keeping in view i have to add a specific no of possible answers ? if i use a formview control in the insert mode after a record is inserted what shud happen ? i am bit confused about this
I have two tables Question(QuestionID,Questi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What the best way to add possible answers?
--Okey, i take it possible answers will be a foreign key in your questions table and might have constraints so it won't accept null value....
in that case you might have default possible answers for example:
Answers Table:
AnswersID Answer
0 0
1 Blue
3 Red
Questions Table:
QuestionID PossibleAnswer CorrectAnswer
1 0 0
2 1 3
How shall i display my form and which control will be good for it ?
You can use formview to insert/update/select (single row) to the DB, but if you just want to display multiple records then i would recommend to use Gridviews....
Hope that helps