Datatable.compute(value) returns (Null) when it shouldn't

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to add the values of a column together where the row meets the
correct criteria. I get inconsistant results and I cannot reason why. Below
is the code.

For x = 0 to dsStations.Table(0).Rows.Count -1
Dim Total As Object = dsTemp.Tables(0).Compute("SUM(MCFAUDIT)", "LSENUM = "
& StationID)
dsStations.Table(0).rows(x).item("Caluclated Result") = Total
Next

Where MCFAUDIT is the column to add, and the row is reporting from the
requested station. LSENUM = StationID.

I am running this against a 700 or so stationID's and for the most part it
works great. However, sometimes I get a value of nothing. Which is odd
because if I manually look at the data, I see that it is all there. The
datatype of the column being calculated is int32. I can see no changes, there
are no odd characters that are making any of the columns referenced into a
string datatype. Everything is numeric, however, I don't see how that would
matter for the stationID filter.

Any ideas why some calls return nothing when the data is there?
 
I figured it out. I did not wrap the stationID in single quotes. It is
apparently a string property. Thus the following:
Dim Total As Object = dsTemp.Tables(0).Compute("SUM(MCFAUDIT)", "LSENUM =' "
& StationID & "'")

returns all the results correctly.

I hate that! ;)
 
Back
Top