I hope this makes sense, I am trying to store a SQL Server 2008 time
(7) datatype in an object.
I am using the below to read the data into the object, but it is crashing out on the line
timeStart = reader.GetDateTime(reader.GetOrdinal("timeStart"))
Other than changing my database field to a datetime, can anyone advise on a solution
My class declaration is:
public DateTime timeStart { get; set; }
public DateTime timeEnd { get; set; }
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Schedules sched = new Schedules()
{
Name = reader.GetString(reader.GetOrdinal("Name")),
timeStart = reader.GetDateTime(reader.GetOrdinal("timeStart")),
timeEnd = reader.GetDateTime(reader.GetOrdinal("timeEnd")),
IntervalMinutes = reader.GetInt32(reader.GetOrdinal("IntervalMinutes"))
};
schedules.Add(sched);
}