How To Fill Strong DataSet DateTime Column With yyyyMMDD Data Valu

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm reading data from a file using OleDbDataAdapter into a strongly type
dataset. One of the columns has a DataType of System.DateTime. The data
that for this column in the file is of format yyyyMMDD. When an
..Fill(dataset.datatable) is executed I receive the following exception:

'Invalid cast from 'Inte32' to 'DateTime'. Couldn't store <20070416> in
XXXX Column. Expected type is DateTime.

How can I read in dates of this format?

Thanks for your help in advance!
 
Well, it's asking for trouble trying to bring an integer column into a
strongly-typed datetime column, although you might be able to do it with an
Expression. Why not just make the database column a datetime also, then do
your format conversions on the UI side of the fence? Alternatively, if you
cannot change the db, you could make the dataset column an integer
(eliminating the exception), then manipulate the integer into a datetime.
 
Back
Top