I am retrieving DateTime
data from an access data base and want to assign it to an object as a string value.
OleDbDataReader dbRead = cmd.ExecuteReader();
while (dbRead.Read())
{
product.DateReleased = dbRead["Date Released"] != DBNull.Value ? (string)dbRead["DATE"] : "No Date available";
product.DatePublished = dbRead["Publish_Date"] != DBNull.Value ? (string)dbRead["Publish_Date"] : "No Date Available";
}
The property of the Product object is a string value and the value I am retrieving from the database is DateTime
.
Trying to run the process gives me an InvalidCastException
exception and I have a feeling it is because of a parsing issue.
Advice perhaps on where the problem is?
Regards