0

Hi,

What is the best way of reading multiple aggregate data ?
like so;

select  id,sum(data1),sum(data2),sum(data3) from table1 group by id

I know with ExecuteScalar you can get one aggregate data, but what about if you have more than one. I tried ExecuteReader and I'm getting exception

sSqlCommand = "select sum(ssk_matrah),sum(g_ssk_matrah )  from per017_ssk  where id= '" + dfSicilNo.Text + "' "
            +" and puantaj_donem='" + dfDonem.Text + " ' and puantaj_ay="+ dfAy.Text+" ";
            OleDbDataReader oku4 = _reader.executar_re(sSqlCommand);
            if (oku4.Read())
            {
                nSSKMatrahi = oku4.GetDouble(0); //here I get exception
                gmatrah = oku4.GetDouble(1);

thanks in advance
snky

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by snakay
0

I assume that the field data type of ssk_matrah field is float.

if (oku4.Read())
   {
            if(!oku4.IsDBNull(0)) {
                nSSKMatrahi = oku4.GetDouble(0); 
                gmatrah = oku4.GetDouble(1);
              }
     }
0

yeah, it is the if(!oku4.IsDBNull(0)) test I!m missing which is why I get exception, because it returns nll

thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.