Trouble entering empty date into Access table from ASP.NET app using ADO.NET

  • Thread starter Thread starter josh
  • Start date Start date
J

josh

Hi,

I have an ASP.NET app that uses ADO.NET for data access. I have a form
that allows a user to enter a date. This date field is not required
however. If they don't enter it, I shove a variable declared of type
System.DateTime that is initialized to null into the database. It
works but if you open the table in Access, the date field contains
12:00 AM. When this value is rendered in an Access form, it shows as
12/30/1899.

What can I do to basically insert null/nothing into that field?

I'm using the System.Data.OleDb library and a parameterized query to
insert this date data into the Access table.

I tried checking for an empty date and substituted the date parameter
value with DBNull.Value but that doesn't seem to remedy the situation.

Thanks for the help,

Josh Blair
Evergreen, CO
 
My bad. Setting the date parameter value to DBNull.Value did the
trick. Cool.

Josh Blair
Evergreen, CO
 
Back
Top