Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Have you tried setting DBNull.Value instead of null?

share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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