I am developing a web application with C# & SQL Server 2008.
I have a data reader which reads the column PlayTime, defined as TIME datatype.
I want to write a function that returns PlayTime‘s value.
private static Timespan GetTime(IDataReader rdr, string columnName)`
{
int index = rdr.GetOrdinal(columnName);
if (rdr.IsDBNull(index))
{
return ; // Here I want to return null or zero
}
return (TimeSpan)rdr[index];
}
-
Am I right using
Timespanfor time data type? -
How to return
nullif datareader value is nothing?
Best Regards,
RedsDevils
Something like this: