Write null Datetime field in Access base (mdb)

Asked

Viewed 153 times

0

Good afternoon to all.

Please I need your help.

I am trying to record/update a Datetime-like Birth field, but not always this field will be populated due to business rule sometimes it will be null.

The base used is Access mdb format.

At the moment of recording/updating I’m not getting, see how I’m doing.:

Example:

public DateTime? Nascimento { get; set; }

cmdInsercao.Parameters.AddWithValue("@NASCIMENTO", Cli.Nascimento);

I tried this:

cmdInsercao.Parameters.AddWithValue("@NASCIMENTO", Cli.Nascimento == null ? (object)DBNull.Value : Cli.Nascimento);

and nothing....

DBNull.Value didn’t roll either..

Someone has a solution

Thank you

  • But what has happened?

  • Good evening Ricardo. Excpetion is : {"Incompatible data type in criterion expression."}.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.