【发布时间】:2011-02-25 17:22:23
【问题描述】:
Public Property Duration() As Integer
Get
Try
Return CType(Item(DurationColumn), Integer)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'Duration' in table 'T_MembershipSale' is DBNull.", e)
End Try
End Get
Set(ByVal value As Integer)
Item(DurationColumn) = value
End Set
End Property
当用户想要将"" 作为Item(DurationColumn) 分配给整数时会发生什么?我得到一个例外。有什么干净的解决方案可以避免这种情况并将0 设置为""?
【问题讨论】: