Message: Object reference not set to an instance of an object

Activity: If / For example: DT_TABLE1.Rows.Count > 0 and DT_Table2.Rows.count > 0
When both the conditions are met it is working good.
But when one condition, f.e. DT_Table2 is not met I get mencioned error.

Message: as above
Exception type: System.NullReferenceException

Can anybody help me to solve this problem?


Try like the following,

(DT_TABLE1 IsNot Nothing AndAlso DT_TABLE1.Rows.Count > 0) AndAlso (DT_TABLE2 IsNot Nothing AndAlso DT_Table2.Rows.count > 0)