Home All Groups Group Topic Archive Search About

How to select on datatable to exclude objects

Author
19 Apr 2006 6:42 PM
Sreppohcdoow
I.e., I want to select all rows in a datatable that don't match a
condition...

Explicitly:

myDatatable.Select("myStringColumn length > 0")

Of course, I could select them all, then check the condition afterward.. is
there a cleaner way?

Thx,

Author
19 Apr 2006 7:37 PM
Norman Yuan
If your condition is "myStringColumn length > 0", is seems that you can
simply:

DataRow[] rs=myDatatable.Select("myStringColumn length = 0")

or

DataRow[] rs=myDatatable.Select("myStringColumn length <= 0")

Assume the row on that column is not nullable. Is this way of one line code
not clean enough?


Show quote
"Sreppohcdoow" <Sreppohcd***@asdf.com> wrote in message
news:u1%23pRE%23YGHA.3752@TK2MSFTNGP03.phx.gbl...
> I.e., I want to select all rows in a datatable that don't match a
> condition...
>
> Explicitly:
>
> myDatatable.Select("myStringColumn length > 0")
>
> Of course, I could select them all, then check the condition afterward..
> is there a cleaner way?
>
> Thx,
>
Author
23 Apr 2006 10:02 PM
Sreppohcdoow
DataRow[] rs=myDatatable.Select("myStringColumn length = 0") is not valid
syntax...

I believe it should be:
DataRow[] rs=myDatatable.Select("Len(myStringColumn) = 0")

No?


Show quote
"Norman Yuan" <NotR***@NotReal.not> wrote in message
news:up6T4h%23YGHA.4688@TK2MSFTNGP04.phx.gbl...
> If your condition is "myStringColumn length > 0", is seems that you can
> simply:
>
> DataRow[] rs=myDatatable.Select("myStringColumn length = 0")
>
> or
>
> DataRow[] rs=myDatatable.Select("myStringColumn length <= 0")
>
> Assume the row on that column is not nullable. Is this way of one line
> code not clean enough?
>
>
> "Sreppohcdoow" <Sreppohcd***@asdf.com> wrote in message
> news:u1%23pRE%23YGHA.3752@TK2MSFTNGP03.phx.gbl...
>> I.e., I want to select all rows in a datatable that don't match a
>> condition...
>>
>> Explicitly:
>>
>> myDatatable.Select("myStringColumn length > 0")
>>
>> Of course, I could select them all, then check the condition afterward..
>> is there a cleaner way?
>>
>> Thx,
>>
>
>

AddThis Social Bookmark Button