I'm doing SELECT
mysql with inner join
within my C # application
MySqlCommand _comandoDados = new MySqlCommand(String.Format(
"select EMGroot.id, EMGroot.lbs_net, EMGroot.lbs_gross_aai, EMGroot.price_brazil, sum(AAIest.qtd_venda) " +
"from eaglemo4_eaglemotorsg.tb_products_root EMGroot " +
"inner join eaglemo4_americai.tb_estoque AAIest " +
"on AAIest.id_produto = EMGroot.id " +
"where EMGroot.manupart = '" + txtManuPartInserir.Text + "'"), conexao_aai);
MySqlDataReader Open_readerteste = _comandoDados.ExecuteReader();
Open_readerteste.Read();
After getting a Reader I should throw the data to some fields, but for there to be no "DATA IS NULL" error, I create the condition HasRows :
if(Open_readerteste.HasRows)
{
root_id = Open_readerteste.GetInt16(0)
....
}
but the result of the condition is always being TRUE
even when there is no
rows
.
Can anyone tell me whether because of inner join
reader
always considers data in the command? or why HasRows always be true?
=================
Updating my question; You will find that HasRows
is always true
because of the sum(AAIest.qtd_venda)
field search. With the sum () tool HasRows will always indicate that there are rows within the dataReader.
Is there a way to work this out?