Friday, October 29, 2004

How to get a nullable DateTime Field or DataColumn?

Janusys has a Calendar Control that allows null values.

But unfortunately I am using Typed Datasets and having a hell of a time to work with null DateTime Values...

You can set the DateTime Field's MinOccurs Property to "", which allows you to store null values.. but then what ???
Like how do you clear it after you assign a date to it ?

Let's say you have two tables in the TypedDataset dsCustomer, Customers and Orders.
The Built in method :
dsCustomer.Customers.AddCustomersRow( .. , .. , .. , .. )
is a great way to make sure you have everything in place,
but what about the hell with the DateTime Fields ??? LastOrderDate ...

By the way, one other issue for ppl that heve not faced it yet, DateTime.MinValue DOES NOT get stored on a SQL Server. It is smaller then the allowed minimum date in SQL. So, if you try to do so, you get an exception right from the SQL server... :)

So, lets say you tweaked it by giving a DateTime.MinDate during the initialization... Then how am I gonna make it null ?

I will tell you when i find about it ...

Duray AKAR