Checking for Nulls

V

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
 
B

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/e...ingannotationswithtypeddataset.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
 
B

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top