I am using a datareader to reader a table. The table may have some null
values in it. The thing is that I need to process the row whether the field
has null values in it or not. The "Swim" field in this table will have null
values in it. The problem is that when I try to read the field with a null
value I get the error message stating:
"unable to cast object of type 'System.DBNull' to type 'System.String'.
reader =if(!reader.IsDBNull(swimcol))
selectCommand.ExecuteReader(CommandBehavior.Single Result);
while (reader.Read())
{
WillUsedList WillUsed = new WillUsedList((int)reader["PoolLoc
"],(string)reader["Swims"]);
{
// use (string)reader[swimcol]
}
else
{
// use some default value maybe null
}
WillUsed. PoolAddr = (int)reader["PoolLoc"];Arne
WillUsed. PollHeat = (string)reader["Swims"];
nuList.Add(WillUsed.PoolAddr);
nuList.Add(WillUsed. PollHeat);
}
reader.Close();