Object reference not set to an instance of an object - System.NullReferenceException -

Version 2018.4.1 - DataTable variable

Carefully examine your code at the reported error location for two variables with the same name (but different scopes).

In my case, I had two datatable variables with the same name (ServOrd) and overlapping scope at the location of the error. I initialized and assigned ServOrd.Scope1 and later referenced ServOrd.Scope2.

1 Like

Hi
This error usually occurs when the activity with variable has no value in it
Kindly check once with the value of the variable associated with the activity where this error occured
Cheers @phillip.dickinson

1 Like

How to check whether the variable has value or not

1 Like

@Sweety_Girl Which variable you needs to check.

1 Like

datatable

1 Like

@Sweety_Girl Follow below condition if(Datatable.Rows.Count=0)
{
||Empty
}
Else
{
||Non Empty
}

1 Like

While it entering if itself it throws object reference error

1 Like

@Sweety_Girl Can you share the screenshot of the if condition

1 Like

in if

Dt.rows.count=0
is being checked

1 Like

@Sweety_Girl Refer this Post

1 Like

Is it same way for other datatypes like string

1 Like

@Sweety_Girl For other data types it is different

1 Like

Can you tell me how for string?

1 Like

@Sweety_Girl String.IsNullOrEmpty(VariableName)

1 Like

Hello @Sweety_Girl,

Thank you for your inquiry.

To maintain the quality of the forum, please provide screenshots and relative information for your question.

String.IsNullOrEmpty(VariableName) or
VarName <> ""

If @indra or myself answered your question please mark it as complete and don’t forget to like the answer. :slight_smile:

regards

2 Likes

As per your request like is provided and the solution is marked by the person who created that topic…

2 Likes

Thank you so much@indra

2 Likes

Happy automation Sweety Girl.

Come back soon!!! :slight_smile:

2 Likes