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

Recommended Answers

All 2 Replies

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);
              }
     }

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

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.