Home All Groups Group Topic Archive Search About
Author
30 Oct 2006 4:23 PM
Vayse
Hi
Using VB.net 2005. In my xsd file, I set the Null value for a field called
Description to "X".However, when I fill the datatable from the access
database, if there is nothing in the Description field, it is still
System.DBNull.

1) What must I change in the XSD file to have the null values replaced with
X?

2) In code, how do I check if a field is null? Comparing to System.DBNull
isn't allowed.

Thanks
Vayse

Author
30 Oct 2006 8:30 PM
Bill B
1) nullValue must be equal to "_empty" and you must set a default value
of "X" for the column.  If you're using the property window, set the
NullValue property to (Empty) and DefaultValue property to "X".

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingannotationswithtypeddataset.asp?frame=true


2) You must use the IsFieldXYZNull() method of the column value to
determine if the value is System.DBNull.

                MyStronglyTypedDataSet.MyStronglyTypedDataTable dtData
= myDataLayer.SelectAll();

                foreach (MyStronglyTypedDataSet.MyStronglyTypedRow
drRowData in dtData.Rows)
                {
                        ...

                        if (drRowData.IsFieldXYZNull() == false)
                            string myData = drRowData.FieldXYZ;

                        ...
                    }
                }

Bill
Author
30 Oct 2006 10:07 PM
Bill Block
1) nullValue must be equal to "_empty" and you must set a default value
of "X" for the column.  If you're using the property window, set the
NullValue property to (Empty) and DefaultValue property to "X".

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingannota...

2) You must use the IsFieldXYZNull() method of the column value to
determine if the value is System.DBNull.

                MyStronglyTypedDataSet.MyStronglyTypedDataTable dtData
= myDataLayer.SelectAll();

                foreach (MyStronglyTypedDataSet.MyStronglyTypedRow
drRowData in dtData.Rows)
                {
                        ...

                        if (drRowData.IsFieldXYZNull() == false)
                            string myData = drRowData.FieldXYZ;

                        ...
                    }
                }

Bill

AddThis Social Bookmark Button