2

I'm looking for advice on the best way to store multiple values using C# and a SQL database, specifically MS SQL Server Express. I can get data into table A and B, but I'm not sure how to store all 10 steps to the database when form 2 is filled out.

The way the application works is a user chooses an item from a combobox on form 1, presses the submit button. Then table A and table B get updated. Once the tables have their values, form 2 opens up and the user fills in the data and submits it to be stored in table B.

As you can see in form 2, I can't imagine having to create 30 radio buttons and 22 textbox fields in table B for each step. Any advice on what direction to take is much appreciated.

EDIT: I know the question was confusing, I apologize I'm confused myself! Basically I just want to store the 10 steps related to a unique id. So when I do a query for say ID 1 it shows the 10 steps associated with that ID.

Using:
Visual Studio Pro 2010
SQL Express 2008
LINQ for the queries to the DB.

Form 2

2
  • I don't understand the question. Maybe using some real world example instead of "table A", "form 2", "data" and "combobox" will help (maybe not). Commented Aug 1, 2011 at 22:42
  • Is it me or is reading this question like watching someone run into a brick wall? We need more context, and more info. Can you tell us table schema? How about the ORM? What have you tried? What did it say when you tried it? Commented Aug 1, 2011 at 22:43

2 Answers 2

1

You can add table C to store the answers. Table B will have an ID field, that will be used by table C to identify the related record in table B.

Table B:

ID, ...
1 , ...
2 , ...

Table C

ID, questionID, Answer
1 , 1         , "value"
2 , 1         , "value"
3 , 1         , "value"
...
10, 2         , "value"
11, 2         , "value"

The questionID field is the relation to table B, and you can determine the answer order by ID field

Sign up to request clarification or add additional context in comments.

Comments

1

As you can see in form 2, I can't imagine having to create 30 radio buttons and 22 textbox fields in table B for each step

From your form, it looks like you need (maybe) 5 fields in Table B.

1) QuestionID (int, foreign key)
2) Answer1 (n/a textbox)
3) Answer2 (radiobutton selection)
4) Answer3 (txt)
5) Answer4 (txt)

Then, you need a lookup table for your questions -- Table C.

1) QuestionID (int, primary key)
2) Question Text (txt)

This sounds like a database design question, not a c# / Sql-server-2008 question...unless I'm misreading it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.