0
I have the following method:
public ClassCardapio MontaCardapioEdit(string periodo, int tipo)
{
ClassCardapio cardapio = new ClassCardapio(_stringconexao);
_conexao.Open();
var sql = $"SELECT " +
"C.DESC_TIPO as 'COMPOSIÇÃO'" +
",B.SEGUNDA " +
",B.TERCA " +
",B.QUARTA " +
",B.QUINTA " +
",B.SEXTA " +
"FROM CARDAPIO A " +
"JOIN CARDAPIO_ITEM B ON A.ID = B.ID_CARDAPIO " +
"JOIN CARDAPIO_TIPO C ON B.TIPO = C.ID " +
"WHERE A.ID = '" + periodo + "' " +
"AND B.TIPO = '" + tipo + "' " +
"ORDER BY B.ID asc ";
var cmd = new SqlCommand(sql, _conexao);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
cardapio.segunda = dr["SEGUNDA"].ToString();
cardapio.terca = dr["TERCA"].ToString();
cardapio.quarta = dr["QUARTA"].ToString();
cardapio.quinta = dr["QUINTA"].ToString();
cardapio.sexta = dr["SEXTA"].ToString();
}
_conexao.Close();
return cardapio;
}
The result of it:
Through its result I am mounting several textbox, the problem is that this select returns 3 lines, because the "type" of these lines are the same, is there any way to force which line of the select will be displayed in each textbox? By default it is always showing the last line of the 3.
Using Break solved my problem, thank you very much!
– Raphael Nobre
@Raphaelnobre I ask you to pay attention to the use of
break
for,break
without being in a conditionif
goes counter-hand with the usewhile
..– Thomas Erich Pimentel