Buenas tengo un inconveniente con esta porción de código, cualquier valor que tome reader simpre ingresa al if y nuca va por el lado del else, lo que necesito es que si el resultado de reader.Read() es false vaya por el else, me puede ayudar? gracias
SqlCommand commandSelect = new SqlCommand(querySelect, conn);
SqlDataReader reader = commandSelect.ExecuteReader();
if (reader.Read())
{
lbFVA.Text = reader["FVA_NDA"].ToString();
lbNCA.Text = reader["NCA"].ToString();
lbFVB.Text = reader["FVB_NDB"].ToString();
lbNCB.Text = reader["NCB"].ToString();
}else
{
MessageBox.Show("No se encontraron datos", "ControlNroFiscal",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
ESta es la consulta que uso: select (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'FVA2020-%' or INVOICEID like 'NDA2020-%')AS 'FVA_NDA', (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'FVB2020-%' or INVOICEID like 'NDB2020-%')AS 'FVB_NDB', (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'NCA2020-%' )AS 'NCA', (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'NCB2020-%' )AS 'NCB'
select (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'FVA2020-%' or INVOICEID like 'NDA2020-%')AS 'FVA_NDA', (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'FVB2020-%' or INVOICEID like 'NDB2020-%')AS 'FVB_NDB', (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'NCA2020-%' )AS 'NCA', (select max(cast(RIGHT(invoiceid,6)AS BIGINT)) from CUSTINVOICETrans R where INVOICEID like 'NCB2020-%' )AS 'NCB'