views:

23

answers:

2

I have a datatable where one column is a float (a system.single). I'm trying to select the rows where that column ("Radius") is less than or equal to 2.5, but getting silly results. (I get 22 rows returned out of 192, but the Radius column of all those rows are greater than 2.5. I tried all kinds of silly things like putting the value in single quotes, putting the column name in brackets, doing just plain less than... I'm stumped. Any ideas?

A: 

You mentioned c#2.0 so I guess you can't use linq

I tried the following:

DataTable table = new DataTable();
table.Columns.Add("Radius", typeof(Single));

for (int i = 0; i < 10; i++)
{
    table.Rows.Add((Single)(i * 0.5));
}

DataRow[] candidates = table.Select("Radius <= 2.5");
foreach (var candidate in candidates)
{
    Console.WriteLine(candidate[0]);
}

and got the following output:

0 0.5 1 1.5 2 2.5

which seems fine to me, can you please share your code?

vc 74
A: 

My actual code was too big (and a bit convoluted) to post here, but in the process of trying to factor it down to something manageable, I discovered my bug. I hadn't looked at a small abstraction layer, assuming the datarows were being passed straight through, but (of course) that's where my error was. Bad debugging on my part... thanks for your help.

Aerik