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

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?
 
C

Cowboy \(Gregory A. Beamer\)

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! |
********************************************
 

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