I have seen similar threads like this where the solution is a tertiary if.
My question is, why even get such an error if Strings are nullable?
I am reading a value of a text column in access using ado.net. Whenever there is a row with an empty text column i get that error.
Culprit:
while (dr.Read())
{
UserList.Add(new UserInfo()
{
.
DestributionGroup = (string)dr["Destribution Group"]
.
}
}
class UserInfo
{
.
public string DestributionGroup;
.
}
Edit:
So in other words I have to convert all of my strings that I am reading from the DB into a line similar to this?
return (accountNumber == DBNull.Value) ? string.Empty : accountNumber.ToString ()
No other way around it?