DateTime to null

S

Shawn Wildermuth (C# MVP)

Hello Alan,

You can't really. You can assign DbNull, but DateTime is a valuetype, therefore
no null...


Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
 
J

Joanna Carter [TeamB]

"Shawn Wildermuth (C# MVP)" <[email protected]> a écrit dans le
message de news: (e-mail address removed)...

| > How do I set a DateTime field to null ?
| > Hence set the DateTimePicker to null?
|
| You can't really. You can assign DbNull, but DateTime is a valuetype,
therefore
| no null...

But, if you are using C# 2.0, you can use Nullable<DateTime> which can be
set to null and you can detect that, setting the database to DbNull where
appropriate.

Joanna
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Will the DateTimePicker accept nullable types?
AFAIK it does expect a DateTime.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DateTimePicker control with the BindingNavigator Toolbar 4
SqlDateTime and DateTime 2
NULL datetime 1
How to... 1
Passing DateTime 5
Assigning null value to DateTime 2
Check if DateTime is valid 1
DateTime Null 2

Top