When checkbox is checked right text from text box to database
<p>I'm trying to create a dynamic list of questions generated from a database.</p>

<p>I get my questions listed with a textbox and checkbox, I would like to have the text from the text box written to the database in a separate table when the check box it checked.</p>

<p>I can write the question to the database but with no answer from the text box.</p>

<p>the code below generates my list.</p>

<pre><code>                    com = new OleDbCommand("SELECT [Task] FROM Debrief_Tasks WHERE [Current] = TRUE AND [Group] = 4", Program.DB_CONNECTION);
                    datareader = com.ExecuteReader();

                    int e = 1;

                    while (datareader.Read())
                    {

                        try
                        {
                            string Task = datareader.GetString(0);

                            Label taskLable = new Label();
                            taskLable.Text = Task;
                            taskLable.AutoSize = true;
                            taskLable.Anchor = AnchorStyles.Left;
                            TextBox nameTextBox = new TextBox();
                            nameTextBox.Name = ToString();
                            nameTextBox.AutoSize = true;
                            nameTextBox.Anchor = AnchorStyles.None;
                            nameTextBox.Padding = new Padding(1);
                            nameTextBoxes.Add(nameTextBox);
                            CheckBox completeCheckBox = new CheckBox();
                            completeCheckBox.Name = Task.ToString();
                            completeCheckBox.AutoSize = true;
                            completeCheckBox.Anchor = AnchorStyles.None;
                            completeCheckBox.CheckAlign = ContentAlignment.MiddleCenter;
                            completeCheckBox.Padding = new Padding(1);
                            completeCheckBox.CheckedChanged += new EventHandler(completeCheckBox_CheckedChanged);
                            completeCheckBoxes.Add(completeCheckBox);


                            tableLayoutPanel5.RowCount = e + 2;
                            tableLayoutPanel5.Controls.Add(taskLable, 0, e + 1);
                            tableLayoutPanel5.Controls.Add(nameTextBox, 1, e + 1);
                            tableLayoutPanel5.Controls.Add(completeCheckBox, 2, e + 1);
                            i++;
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
    }

    void completeCheckBox_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox checkBox = (CheckBox)sender;



        if (checkBox.Checked)
        {

            OleDbCommand com = new OleDbCommand("INSERT INTO Debrief ([Debrief_Date], [Task], [DoneName]) VALUES (?, ?, ?)", Program.DB_CONNECTION);
            com.Parameters.Add(new OleDbParameter("", DateTime.Today.Date));
            com.Parameters.Add(new OleDbParameter("", Convert.ToString(checkBox.Name)));
            com.Parameters.Add(new OleDbParameter("", ***Convert.ToString(checkBox.Name***)));


            OleDbDataReader datareader = com.ExecuteReader();
        }
        else
        {
        }
    }
</code></pre>

<p>I know my last sql input is the same as the other but this is the only way I can get it to run.</p>

<p>Any ideas how to link the relevant text box to the checkbox.</p>
