我有一个类型为SqlString的属性,该属性目前正在返回Null。
_oData.Customer.Name
以下是我尝试过的以下未起作用的检查。
IsNothing(_oData.Customer.Name)
_oData.Customer.Name.IsNull
_oData.Customer.Name.Value IsNot Nothing
_oData.Customer.Name = Nothing每一个结果都会导致下面的错误。如何才能真正地检查出这个值是空的。
数据为空。不能对空值调用此方法或属性。
_oData.Customer具有其他属性的值。
编辑
添加具有name属性的类。下面是如何在Customer类中定义它
Private mName As SqlTypes.SqlString
Public Property Name() As SqlTypes.SqlString
Get
Return mName
End Get
Set(ByVal value As SqlTypes.SqlString)
mName = value
End Set
End PropertySqlString在SqlTypes名称空间中的应用

编辑-2
Ok似乎是处理ternery操作的一个问题。
这行得通
If _oData.Customer.Name.IsNull Then
CName = ""
Else
CName = _oData.Customer.Name
End If这可不是
CName = IIf(_oData.Customer.Name.IsNull, "", _oData.Customer.Name.Value)有人能告诉我为什么在使用三元运算时这个方法不起作用吗?
发布于 2017-11-01 15:43:25
您应该使用Microsoft.VisualBasic.Information.IsDBNull()方法:
If IsDBNull(_oData.Customer.Name) Thenhttps://stackoverflow.com/questions/47045873
复制相似问题