Strange DataTable behavior

There is strange behavior in my code that I cannot explain ... I worked on it, but I would like to know the reason for this behavior.

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 only table in the dataset:

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

      

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

I want the filter to filter it out so that the only lines I get are the ones with the correct file ...

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

but filter string "FileID = 2" will return 0 rows ... Filter like "FileID <> 1" returns 2 rows correctly.

I really can't explain this od behavior, maybe one of the communities. There are more records in the table, but the filter string only works with the "FileID = 1" selection.

Sorry my bad english.

Please explain my mistake to me.

+2


a source to share


2 answers


What data type is the FileID column? Is it possible it is some kind of string and those with 2 contain some kind of spaces?



+1


a source


It is read from an 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 it unreadable as a comment. Real DocSnuggles :)

0


a source







All Articles