By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

Datetime field in SQLserver database empty?

P: n/a
Hi,

I've got the next problem: I have a datetime field in my database
(sql-server) and I want the option in it that this field can be empty. But
if I leave that datetime field empty I get the error:

"The value you entered is not consistent with the data type or length of the
column."

Is it possible to leave that field empty and how is it possible? If not what
do I have to do to leave it empty, because in my application this (date) is
not a required field?

Thanks for your help,

Thierry
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If someone else knows a better way I'm all ears,

The only way I know how to have a truly empty date is to allow nulls in the
datetime field. Then in code, you can set the variable you are updating
with to System.DBnull.Value. Or if you are working off typed datasets, you
can use myDataSet.myTable(rowNum).setField_NameNull(), at least something
like that I'm not sure if that syntax is correct.

--Michael
"Thierry" <Th*****@nospam.com> wrote in message
news:rX*********************@phobos.telenet-ops.be...
Hi,

I've got the next problem: I have a datetime field in my database
(sql-server) and I want the option in it that this field can be empty. But
if I leave that datetime field empty I get the error:

"The value you entered is not consistent with the data type or length of the column."

Is it possible to leave that field empty and how is it possible? If not what do I have to do to leave it empty, because in my application this (date) is not a required field?

Thanks for your help,

Thierry

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.