Strange DataTable behaviour

Posted by DocSnuggles on Stack Overflow See other posts from Stack Overflow or by DocSnuggles
Published on 2010-05-04T10:30:31Z Indexed on 2010/05/04 11:58 UTC
Read the original article Hit count: 147

Filed under:
|

There´s a strange behaviour in my code which I can´t explain... I have worked arround it but I´d like to know the reason of this behaviour.

My Code:

If dataset.Tables.Count > 0 Then
            Dim rows() As DataRow = dataset.Tables(0).Select("FileID = " + fileid.ToString)
            For Each row As DataRow In rows...

the one and only table in dataset is:

18  1   1   testpara42          
19  1   2   Para2               
23  2   1   Para1               
24  2   2   Para42   

Where the colums are: ParamID - FileID - ParaPos - Paravalue.

I want do filter it so that the only rows I get are the ones with the correct fileid...

the result when the selection string is "FileID = 1" is an array with 2 rows...
everything is fine...

but the filter string "FileID = 2" will return 0 Rows... A filter like "FileID <> 1" returns 2 Rows correctly.

I really cant´t explain this od behaviour, maybe one of the community does. The Table does have more entries but the Filter string just works with the "FileID = 1" selection.

Excuse my bad english.

Please explain my mistake to me.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about datatable