Is there any way to optimize code below. I'm using 3 executeReader for different results
SqlCommand command = new SqlCommand("select DeliveryID,Name from deliveryphone WHERE PhoneNumber= '" + textBox1.Text + "'", con);
SqlDataReader read = command.ExecuteReader();
while (read.Read())
{
SqlDeliveryID = (read["DeliveryID"].ToString());
textBox2.Text = (read["Name"].ToString());
}
read.Close();
SqlCommand command2 = new SqlCommand("select Adress from DeliveryAdress WHERE DeliveryID= '" + SqlDeliveryID + "' ", con);
SqlDataReader read2 = command2.ExecuteReader();
while (read2.Read())
{
comboBox1.Items.Add(read2["Adress"].ToString());
}
read2.Close();
SqlCommand command3 = new SqlCommand("select top 1 Adress,Location,Floor,Comments from DeliveryAdress WHERE DeliveryID= '" + SqlDeliveryID + "' order by DefaultAdress desc", con);
SqlDataReader read3 = command3.ExecuteReader();
while (read3.Read())
{
comboBox1.Text = (read3["Adress"].ToString());
textBox3.Text = (read3["Location"].ToString());
comboBox2.Text = (read3["Floor"].ToString());
textBox5.Text = (read3["Comments"].ToString());
}
Is there any way to combine this 3 reader into 1?