DateTime from Database

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hi All

I am having a problem retrieving a Date value from an
Access 2000 database using the OLEDbProvider. Can someone
tell me please how to create a DateTime Object with the
date fro m the Database, I need the database date to
subtract it from another date I have to gain the number
of days that have elapsed. I just cannot seem to get this
DateTime thing correct. The field in my Access Database
is defined as a short date. This is kind of what I
tried :


DateTime EmpShStart =new DateTime();
foreach (DataRow dr in ds911.Tables
["Employees"].Rows)
{
EmpShStart = Convert.ToDateTime(dr.Table.Columns
["ShiftStartDate"]),"d",CultureInfo.CurrentCulture,DateTim
eStyles.NoCurrentDateDefault);
}

but that doesn't work, I have tried numerous
combinations, but all of them throw an exception! any
ideas?

Also Can someone Please direct me to a site or something
that actually explains the DateTime class very well,
becasue I have such problems creating objects of the
Datetimes class. I think it would be helpful if I could
read some material that explains the DateTime class in
simple english so that I can understand it well, so that
in the future I don't have these hassles.

Thanks very much for any help

Kevin
 
Kevin try to change in the insert command parameters, the type of the
parameter assigned to the datetime field to be assigned to a datetime type.
This is a bug of oledb adapters, to generate the parameters for the datetime
type wrong.

Hope this helps
Dan Cimpoiesu
 
Back
Top