0

enter image description here

  1. Code is error

sum1 = Convert.ToInt32(dtt.Compute("Sum(BIN1)" ,string.Empty));

  1. how can I display on Listbox and just show columns name.
DerStarkeBaer
  • 669
  • 8
  • 28
  • `dtt.Compute("Sum(BIN1)"` is returning `DBNull`. You want to convert that to `int`. There is no meaningful way to do that. What do you want `sum1` to be if the sum is `DBNull`? 0? 44? Something else? – mjwills Sep 27 '19 at 02:09
  • if(sum1 == 0), I want to remove colunm "BIN1" on datatable. – Lalita Senaktang Sep 27 '19 at 02:16
  • To correct this error, please refer to [Object cannot be cast from DBNull to other types](https://stackoverflow.com/questions/6098646/object-cannot-be-cast-from-dbnull-to-other-types) – 大陸北方網友 Sep 27 '19 at 05:51

1 Answers1

0
1.public static object DBNullValueorIntIfNotNull(int value)
    {
        object o;
        if (value <= 0)
        {
            o = 0;
        }
        else
        {
            o = value;
        }
        return o;
    }

2.if(sum1 == 0) { columns name .visibale = false;}