views:

39

answers:

2

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.

+1  A: 

What datatype is the FileID column? Is it possible that it's a string of some kind and the ones with 2 in them contains some kind of whitespace?

ho1
A: 

It´s read out of a XML-File.

<Table>
 <ParamID>18</ParamID>
 <FileID>1</FileID>
 <ParaPos>1</ParaPos>
 <ParaValue>testpara42 </ParaValue>
 </Table>
<Table>
 <ParamID>19</ParamID>
 <FileID>1</FileID>
 <ParaPos>2</ParaPos>
 <ParaValue>Para2 </ParaValue>
 </Table>
<Table>
 <ParamID>23</ParamID>
 <FileID>2</FileID>
 <ParaPos>1</ParaPos>
 <ParaValue>Para1 </ParaValue>
 </Table>
<Table>
 <ParamID>24</ParamID>
 <FileID>2</FileID>
 <ParaPos>2</ParaPos>
 <ParaValue>Para42 </ParaValue>
 </Table>

Sorry for Posting it as an answer... Put as a comment its unreadable. The Real DocSnuggles :)

Doc Snuggles