I am reading a result from a MS SQL 2008 Database with a column type of dbtype.time from a datareader, using c# with DAAB 4.0 framework.
My problem is the MSDN docs say dbtype.time should map to a timespan but the only close constructor for timespan I see accepts a long, and the result returned from the datareader cannot be cast to a long, or directly to a timespan.
I found this Article whichs shows datareader.getTimeSpan() method, but the datareader in daab 4.0 does not seem to have this method.
So how do I convert the result from the datareader to a timespan object ?
GetTimeSpan
is a method ofOleDbDataReader
andSqlDataReader
(but not of the more generic IDataReader interface which DAAB'sExecuteReader
returns). I'm assuming that theIDataReader
instance which DAAB has returned to you is actually an instance ofSqlDataReader
. This allows you to access theGetTimeSpan
method by casting theIDataReader
instance appropiately:Edit: If the
IDataReader
instance is not aSqlDataReader
then you might be missing theprovider
attribute of your connection string defined in your app.config (or web.config).