I am using IRowBuffer/IFeatureBuffer to insert fields to SQL Server 2008 DB.
When inserting a field I am using:
public void SetValue(IRowBuffer buffer, string field, object value)
{
int fieldIndex = buffer.Fields.FindField(field);
buffer.set_Value(fieldIndex, value ?? DBNull.Value);
}
(meaning when inserting null value I am using DBNull.Value)
Using this code with integer/float fields with null value works without a problem.
But using this with DateTime result in the value:
01/01/0001 00:00:00
in the DB.
Edit: a bit more clarification
When using:
buffer.set_Value(10, DBNull.Value);
When 10 is the index for a nullable int field the DB has a value of null.
But when 10 is the index for a nullable datetime field the DB has a value of 01/01/0001 00:00:00 .
It's not a problem in .Net or using nullable types but rather a problem with ArcOjects.
I have already seen Null values in plugin data source
Do someone have a solution for this? Am I doing something wrong?