How do you appropriately setup a plugin data source to allow for null values (in .NET - C# preferred)?

I'm currently setting up a field using:

field.Type_2 = esriFieldType.esriFieldTypeSingle;
field.IsNullable_2 = true;
field.Name_2 = "Foo";

Then, later, during the cursor's QueryValues call, I'm trying to set a null value via:

// Given: public int QueryValues(IRowBuffer row)
row.Value[i] = null;

However, the value always maps through as 0, not null. How do you properly setup the data source in a plugin data source to allow for a null value?


Have you tried setting DBNull.Value instead of null?

| improve this answer | |
  • Thanks! I hadn't tried that, as their examples show setting it to null directly - but this does actually work (where the other doesn't). – Reed Copsey Feb 21 '11 at 23:27
  • The documentation is sometimes null and void :) Do you have a link to this example? – Kirk Kuykendall Feb 22 '11 at 16:39
  • I believe most of the .NET samples were converted from VB rather badly, perhaps semi-automatically I guess. In .NET COM interop, the VT_NULL (Null in VB/VBA) variant, which is used for denoting null values, maps directly to DBNull in .NET. – Petr Krebs Feb 22 '11 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.