DataRow?

  • Thread starter Thread starter Charles A. Lackman
  • Start date Start date
C

Charles A. Lackman

Hello,

I am working with DataRows and I am using the following:

DataRow = Dataset.Tables("MyTable").Rows(0)

If DataRow("ID") = Nothing Then
'Do Something
Else
'Do Something Else
End If

The problem is that even though there is a value for ID the If... Then
Statement is acting like there is Nothing.
I have checked the value and the DataRow does contain an ID. It is like
there is something wrong with the Runtime and Nothing is not being
interpreted correctly. I have simular instances of this in the same program
and they work like expected.

Any Suggestions would be greatly appreciated,

Chuck
 
Hi Charles,

You should use Is instead of operator =.
If DataRow("ID") Is Nothing Then
....
Furthermore you should compare the value with DBNull.Value instead of
Nothing.
If DataRow("ID") Is DBNull.Value Then
 
Hi Miha,

There exist a Datarow("ID") Is Nothing situation,

That is with an XML dataset where some elements don't exist in a row, but I
think also that that is not in this situation.

Cor
 
Back
Top