How I will combine the while and if in data reader? I tried this but in while DR1.Read
it does not gives me all the result
if(DR1.Read())
{
while(DR1.Read())
{
flowLayoutPanel1.Controls.Add(label);
}
}
else
MessageBox.Show("No results found")
Try this:
if (DR1.HasRows)
{
while (DR1.Read())
{
flowLayoutPanel1.Controls.Add(label);
}
}
else
MessageBox.Show("No results found");