in access 2003, i created a date/time field, appDate, and set it to general date, which shows exactly as the rendered date below
then i try to update it with
Using command As New System.Data.OleDb.OleDbCommand("bapps3insert", db)
'Set the commandtype
command.CommandType = Data.CommandType.StoredProcedure
'Specify the parameters
Response.Write("datetime.now = " & DateTime.Now & "</br>")
command.Parameters.AddWithValue("appDate", DateTime.Now)
etc. appDate is in the query string, but get the data mismatch error,
I was following this tutorial, http://www.mikesdotnetting.com/Article/92/MS-Access-Date-and-Time-with-ASP.NET, which i thought indicated i could use the above syntax and date format
the response.write rendering of the date was "9/28/2009 2:32:11 PM" - just to be clear w/o the quotes
there should be someway to update an access date/field set to general date, with a date and time combo
i change the date variable to, command.Parameters.AddWithValue("appDate", DateTime.Now.Date)
the update goes fine, however, as expected, i only get the date and no time, i want the date to include the time
in the past with traditional asp and access2000, i've updated an access date/time field with Now() and get the combo date time field, essentially i'm trying to do the same thing now with .net and using datetime.now instead of now()
bbxrider
Member
105 Points
329 Posts
access date/time, - data mismatch error
Sep 30, 2009 06:07 PM|LINK
in access 2003, i created a date/time field, appDate, and set it to general date, which shows exactly as the rendered date below
then i try to update it with
Using command As New System.Data.OleDb.OleDbCommand("bapps3insert", db)
'Set the commandtype
command.CommandType = Data.CommandType.StoredProcedure
'Specify the parameters
Response.Write("datetime.now = " & DateTime.Now & "</br>")
command.Parameters.AddWithValue("appDate", DateTime.Now)
etc. appDate is in the query string, but get the data mismatch error,
I was following this tutorial, http://www.mikesdotnetting.com/Article/92/MS-Access-Date-and-Time-with-ASP.NET, which i thought indicated i could use the above syntax and date format
the response.write rendering of the date was "9/28/2009 2:32:11 PM" - just to be clear w/o the quotes
there should be someway to update an access date/field set to general date, with a date and time combo
i change the date variable to, command.Parameters.AddWithValue("appDate", DateTime.Now.Date)
the update goes fine, however, as expected, i only get the date and no time, i want the date to include the time
in the past with traditional asp and access2000, i've updated an access date/time field with Now() and get the combo date time field, essentially i'm trying to do the same thing now with .net and using datetime.now instead of now()
hans_v
All-Star
35998 Points
6551 Posts
Re: access date/time, - data mismatch error
Oct 01, 2009 01:55 AM|LINK
DateTime.Now also includes miliseconds, and access doesn't understand that. To overcome this, convert the DateTime field to an Ole Automation Date:
command.Parameters.AddWithValue("appDate", DateTime.Now.ToOADate)
bbxrider
Member
105 Points
329 Posts
Re: access date/time, - data mismatch error
Oct 01, 2009 04:35 AM|LINK
thank you, thank you, thank you, finally a reply, and one that works!!!
one final if i may, is there a heads up for other variable types that need to consider ole automation?
or put another way, is there some way to understand in general how/where ole automation comes into play?
bob
hans_v
All-Star
35998 Points
6551 Posts
Re: access date/time, - data mismatch error
Oct 01, 2009 05:10 PM|LINK
You're welcome....
No, all other data types do work. it's the DateTime type that is causing the problems when it include miliseconds....