I have a result set with some times stored in DateTime variables. If the value is null I want to set the var to the string “Still logged in”.
I’ve tried some toString() things but had no luck yet.
This is the code that doesn’t work. queryResult.Egresstime is type DateTime and can’t be a string.
if (Convert.IsDBNull(rdr["timeOut"]))
{
queryResult.Egresstime = "Still logged in";
}
That seems like a flaw in design but if you absolutely must keep it like this, you could set it to a precise date ridiculously far in the past and check before rendering the date to render “Still logged in” if it’s that particular date. That is a terrible way to design things though!