I have a table in my DB containing a column of type Datetime, which allows null values. I created DataSet on which I drag&droped this table. Everything was fine, DataTable with TableAdapter have been successfully created and are both working. When I select this column in this DataTable (on designer surface) it shows in properties that this column is indeed nullable (AllowDBNull: True).

However ADO.NET generated false code for this example. Look at the following code:

var t= new ABCTableAdapter().GetData();
ticket[0].MyNullableColumn -> this return 'Datetime' instead of 'Datetime?'.

If a given record in DB has indeed null value in this column, then such code generates "StrongTypingException". So this is quite clear that ADO.NET made some mistakes in code generation.

I tried deleting all DataSet and recreating it from scratch. Also I`m sure that my column really allows null values as some records have such value in this column.

Could you please help me and tell how am I supposed to force ADO.NET to generate this code properly? I want the following code to compile:

if (t[0].MyNullableColumn != DBNull.Value) {...}