Which of IsDBNull and IsNull should be used?

后端 未结 7 1976
傲寒
傲寒 2021-01-07 23:02

If in VB.NET I have DataRow and I want to test whether a column value is Null, should I use:

myDataRow.IsNull(\"Column         


        
7条回答
  •  情话喂你
    2021-01-07 23:27

    When dealing with DataRow data, it's ideal to use the IsDBNull() function. IsDBNull() has the advantage that it checks if your object represents a null, rather than simply being null itself, and that's an important difference. When you are interrogating a data row item which is null in the database, the item itself exists as an object, but it represents a NULL value. If you use IsNull() you will miss NULL values.

提交回复
热议问题