Should min (5) be less than or equal to max (-1) in the Range object?

I get an error in internal foreach when using Select in datatable .

Here is the code I've tried so far

 foreach (DataRow drOuter in dtLogic.Select("Name='>' OR Name='='")) { foreach (DataRow drInner in dtLogic.Select("ParentId=" + Convert.ToInt64(drOuter["Id"]) + "")) { } } 

where Convert.ToInt64(drOuter["Id"]) has the value 2107362180 when I checked in the Immediate Window .
Then why does this cause an error below?

enter image description here

+5
source share
1 answer

You must check strings, not numbers, to insert single quotes in the query expr='string'

 foreach (DataRow drInner in dtLogic.Select("ParentId='" + Convert.ToInt64(drOuter["Id"]) + "'")) { } 

after this edit you can replace as @Christos answer says

 Convert.ToInt64(drOuter["Id"]) 

from

 drOuter["Id"].ToString() 
+11
source

Source: https://habr.com/ru/post/1210397/


All Articles