Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Min (5) must be less than or equal to max (-1) in a Range object?

I am getting the error in the inner foreach while using Select in datatable.

Here is the code I 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"]) have the value 2107362180 when I checked in Immediate Window.
Then why does it throw the below error?

enter image description here

like image 437
Shilpa Praneesh Avatar asked Jan 05 '15 11:01

Shilpa Praneesh


1 Answers

You should check for strings and not for numbers so insert single quotes in 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"])

with

drOuter["Id"].ToString()
like image 139
faby Avatar answered Nov 16 '22 20:11

faby