Question: There's a dropdown displaying 1-10 from where the user selects the number of textboxes he wants - if he chooses unlimited, it shows him a textbox wherein he enters the exact number of textboxes he'd like. if he enters 40, it shows him 40 textboxes which are created at runtime.

My question is, how do I enter the data from 40 - or 'whatever number he enters' textboxes into the MS SQL database. There's no way I can create a column name dynamically, and that'd be too tedious and messy. Is there any way I can do this?

Answer: 
What you have is a 1-to-many relationship between whatever it is that is on that page and the comments or descriptions or whatever. You shouldn't have this modeled in your database as text\_box\_1, text\_box\_2, etc. Instead, it should be:

```
CREATE TABLE Some_Entity
(
    some_entity_id  INT NOT NULL,
    CONSTRAINT PK_Some_Entity PRIMARY KEY CLUSTERED (some_entity_id)
)
GO

CREATE TABLE Some_Entity_Comments
(
    some_entity_id  INT     NOT NULL,
    comment_number  INT     NOT NULL,
    comments        VARCHAR(1000)   NOT NULL,
    CONSTRAINT PK_Some_Entity_Comments
         PRIMARY KEY CLUSTERED (some_entity_id, comment_number),
    CONSTRAINT FK_Some_Entity_Comments_Some_Entity
         FOREIGN KEY (some_entity_id) REFERENCES Some_Entity (some_entity_id)
)
GO

```

Once that's done, you can use code similar to what Mun wrote to handle things on the front end. You'll just pass the text box index as the comment\_number.
Have you considered storing the data as an XML field in the database?

If you have 40+ text boxes you could just have a simple schema to store them like:

```
<YourData>
    <TextBox ID="TextBox1">Value1</TextBox>
    <TextBox ID="TextBox2">Value2</TextBox>
    <TextBox ID="TextBox3">Value3</TextBox>
    ... etc ...
</YourData>

```

No need for dynamic fields in your DB. You should also store the schema somewhere as well. This is a good way to store dynamic data that can change from record to record.