I have conditional logic that checks two DataRows
foreach (DataRow dr in dtClients)
{
if (Convert.ToBoolean(dr["NewClient"] == true && dr["ClientStatus"].ToString().Equals("Sign Up"))
{
// do stuff
}
}
The dtClients
is populated from the database. In my local dev environment, this code works as expected but on my UAT environment it is deployed to, I receive the error “Specified cast is not valid.” And the stack trace leads right to the if()
statement above.
I’ve checked the appropriate table and the columns that the above code refer to are the same (BIT and VARCHAR(15)) on my local vs UAT. I cannot for the life of me figure out why I am getting an error on one environment but not another.
Any suggestions?