How to check that the DataTable parameter has never been set, that is, it will be Null or Nothing ? I do not mean an empty DataTable .
For instance:
Dim dt As DataTable = TryCast(Session("dt"), DataTable) If dt.Rows.Count <> 0 Then 'Do something ! End If
If for some reason Session("dt") never set or lost in memory, dt.Rows.Count <> 0 will throw this exception:
The reference to the object is not installed in the instance of the object.
source share