dave

dave

  • NA
  • 3
  • 0

How do You Retrieve/Return a Non-Integral Datatype from a Dataset?!?

Feb 8 2007 1:16 PM
Hello all,

I hope someone can help me with this.  I have one datatable in a dataset with 5 columns.  The columns are named originally enough Column1, Column2...5. 

I can insert data into the dataset/table as a Decimal or Double just fine.  I know the data being inserted is of type double because I am simultaneously writing to output the contents as a string and it shows 3.2, .4, etc.  But when I attempt to retrieve the data from the dataset in order to sum rows, it will only return Integer-type data (and therefore I lose all my decimals and get 0 instead of .4, 3 instead of 3.2, etc!!!

I have made the underlying Column5 in my datatable datatype both Decimal and Double but neither works. 

Effectively, I am attempting this:

Dim amt as Double
Dim temp2 as Int32
Dim endc as Int32
'Add up the amt
While (temp2 < endc)
        amt += ds.Tables(0).Rows(temp2).Item(4)  '<== THIS RETURNS IN INTEGER, SO VALUE OF .4kb WILL BE REPORTED AS AN INTEGER OF 0kb !!!
End While

I additionally tried this:

        amt += Convert.ToDouble(ds.Tables(0).Rows(temp2).Item(4))

But this converts it to a Double AFTER the fact so it becomes 0.0. 

Can anyone help me?  In Visual Studio, at run-time, in my Watch List I see that the value of "ds.Tables(0).Rows(temp2).Item(4)" is described as an Integer even though the underlying column datatype is double and the data is being inserted as a Double!   I basically need to be able to sum certain rows in my dataset (such as summing rows 2 -5 to row 1, like to a parent, rows 7 - 10 to 6, etc.)

Thanks a zillion in advance!
Dave