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?
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With