In Typed DataSets we set AllowDBNull property to true if that particular
Column allows to have a null value.

Remember these rules for the AllowDBNull Columns in Typed DataSets

1) TextBox1.Text = TypedDataTableRow.DateOfBirth;
this line can throw exception if DateOfBirth is NULL use IsDateOfBirthNull()
before reading value. Although you can change this behavior (of throwing
exception) by changing value of NullValue property of that particular
column.

2) TypedDataTableRow.DateOfBirth = null;
above is NOT allowed since DateOfBirth is of type DateTime. So you must use
SetDateOfBirthNull() in order to set a NULL value in this column.

Do NOT change the xsd file since these are auto generated files and will
change automatically if you do a slight change in DataSet.



On Wed, Jan 19, 2011 at 11:07 PM, PawBoc <[email protected]> wrote:

> Hello.
>
> I am newbie. I write small application, I decided to use Typed
> DataSets as DB access layer. I have a problem with null values at
> DataBase.
>
> During creating of DataSet classes from tables I figured out, that
> "Tool" does not set nullable properties for null-allow columns in
> database. In example: DateOfBirth property (which is not mandatory
> param) is not generated as DateTime?.
> I have opened xsd and tried tu put msprop:nullValue="_null". But after
> that "Tool" did not generated this property at all. I could not set
> (Null) from graphic generator.
> I also figured out, that there are methods: IsDateOfBirthNull() and
> SetDateOfBirthNull() - are those any way to handle nulls?
>
> I also found, that methods for DataAdapter like Update... contains
> those not null values. How to handle them? Currently I copy them to
> other code-file and overwrite them with nullable types, but this seems
> to be a little overwhelming.
>
> So - what is the most frequently used approach to null values?

Reply via email to