Question

How to read the empty values from the "dbf" file in C#. Currently while reading the dbf files, the empty values in the file are automatically getting converted to default values. Like empty decimal field is converted to "0.000". Can someone please help in way to read the empty fields as they are and not as default values.

Was it helpful?

Solution

The .dbf file format dates back to the stone age of computing. It never had a notion of an "empty" column value, unassigned fields would get a default value. Support for nullable columns didn't come around until FoxPro. I reckon what you ask for isn't possible.

OTHER TIPS

Can you declare your variables (at least the value types) as nullable types:

decimal? myDecimal = null;

Then if there's no value in the field it should be left as null and not set to a default value.

The syntax T? is shorthand for Nullable, where T is a value type. The two forms are interchangeable.

decimal is a so-called value type and it cannot be null, which is probably why you are getting those default values. However, most databases have a notion of empty values (DbNull), so it would most likely just be a question of reading the value correctly. If you post some code we should be able to help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top