0

I'm trying to save a null in an integer column with arcObjects but it always save 0 when the value is null. Can anyone explain me what is happening? I am developing in C#.

I tried to assign DBNull.Value to my variable but I can't because it's an integer. Thank you very much for your time and your knowledge!

Visual Studio side:

enter image description here

Visual Studio Side

ArcGIS side:

ArcGis Side

tornic
  • 747
  • 6
  • 15
  • `int` being a value type it will have a value defaulted to 0. Why don't you use nullable int [`int?`](https://msdn.microsoft.com/en-us/library/2cf62fcy.aspx) instead? – L J Jan 11 '17 at 16:40
  • I tried it. When type is int?, I set null for the variable and it records 0 on DB, not null – tornic Jan 11 '17 at 16:41
  • Could you please share the relevant code, so that we could take a look? – L J Jan 11 '17 at 16:42
  • I wish the edit helps. thank you for your time L J – tornic Jan 11 '17 at 16:58

3 Answers3

2

U need DBNull

... = (entry.Value == null) ? DBNull.Value : entry.Value;
1

Solved!!

Setting DBNull in this point the problem dissapear:

enter image description here

tornic
  • 747
  • 6
  • 15
0

Shapefile does not support Null in field value and converts it to default value ie 0 for integer types. In a Geodatabase, the field "Allow NULL values" property should be set to "Yes".