Identify a field with a null value in a Strongly Typed DataSet

  • Thread starter Thread starter michael
  • Start date Start date
M

michael

I have a Strongly Typed DataSet. I need to know if the value of a field in a
row is DBNULL.value before I use it. I have been obtaining the StronglyTyped
DataRow of the table and testing to see if it's "is DBNULL.value". However,
I'm getting the following exception thrown when the value truly is null:

Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The
value for column 'PID_F18_C2' in table 'CEN_Segment_PID_A' is DBNull.", e)
End Try

If instead of testing the strongly typed datarow I use an ordinary DataRow,
I can easily do the test "drTestRow is DBNULL.value".

How can I test if a value in a StronglyTypedDataRow is null?
 
When you create a strongly typed dataset, every null field (field that can
be null) has a separate "is" method.

For example, if the property is Title, you will find an IsTitleNull()
method. Query that first, like this:

if(!DataSetName.TableName.IsFieldNameNull())
{
//Work with field
}

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
Back
Top