I’m trying to load a SQL row of numbers into multiple text boxes. Basically the row contains numbers separated by “;”. How can I get it so that each number when separated by “;” is in their own textbox?
SqlConnection conn = new SqlConnection("Data Source=LAURA-PC;Initial Catalog=Sudoku;Integrated Security=True");
conn.Open();
SqlCommand command = conn.CreateCommand();
command.CommandText = "Select puzzle from Puzzle";
command.CommandType = CommandType.Text;
SqlDataReader reader = command.ExecuteReader();
if (reader.Read())
{
textBox1.Text = reader.GetValue(0).ToString();
textBox2?
textbox3?
}
conn.Close();
Assuming that you have the same amount of (or fewer) numbers than TextBoxes , you could put your TextBoxes into an array and use the following code: