Read empty values โ€‹โ€‹as empty, not as default

How to read empty values โ€‹โ€‹from a "dbf" file in C #. Currently, when reading dbf files, empty values โ€‹โ€‹in the file are automatically converted to default values. How an empty decimal field is converted to "0.000". Someone can help to read empty fields as they are and not as default values.

+2


a source to share


3 answers


The .dbf file format dates back to the calendar age of computing. It never had the concept of "empty" column value, unrecognized fields will get the default value. Null column support did not appear until FoxPro. I believe what you are asking is not possible.



+1


a source


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

decimal? myDecimal = null;

      



Then, if there is no value in the field, it should be left null and not set to default.

Syntax T? is shorthand for Nullable, where T is the value type. These two forms are interchangeable.

+1


a source


decimal

is the so called value type and it cannot be null, which is probably the reason you get these defaults. However, most databases have the concept of null values โ€‹โ€‹( DbNull

), so most likely it's just a matter of reading the value correctly.If you post the code, we can help you.

+1


a source







All Articles