0

I am looking for a way to create conditions dynamically in a C#/winform front end with a SQL back end. Right now it is a dynamically generated question and answer form. The database has one table with the questions and another with the possible answers. I add a label with the question and a combo box with the answers. I have all of that working. My issue is I can't come up with a way to create conditions. An example being if someone answers "Yes" to question 2 then they have to answer 2a and 2b or if they answer "No" then 2a and 2b become "N/A". How do I create that link? Can I store an if statement in the database and pass it into the program?

Edit:It is more of a survey. There are no right or wrong answers.

Jeebwise
  • 177
  • 2
  • 2
  • 12
  • Try adding a new bit(boolean) column on the answers table, so you can even check if the given answer is correct on the database. – kevinrodriguez-io Oct 28 '15 at 17:16
  • Sorry, I should have specified. There are no right now wrong answers. It is more like a survey. The answers they give will be stored when they are done. – Jeebwise Oct 28 '15 at 17:19
  • 2
    [**Survey Database Design**](http://stackoverflow.com/a/5858666/342740), ***This is just a table design example for survey but I think you can learn a lot from this*** and it already takes into consideration when a question is a condition for another, as you can see on the dependent field. Even tough its not for MSSQL the design still applies with minor if no changes at all. – Prix Oct 28 '15 at 17:20
  • You could add 2 fields to each question that lets it say it is dependant on another question and what the answer should be for it to show – pquest Oct 28 '15 at 17:20
  • That link was what I wanted. Using that design I adapted it to what I needed and now I have dynamic conditions working. Thank you. – Jeebwise Oct 30 '15 at 17:41

0 Answers0