Object reference is not set to an instance of an object in Assign Activity

I wanted to take the value of datatble1 of column2 in in datatable2 of column2.
So for this I have used assign activity:

datatable2.Column(2)=datatable1.Column(2)

But i m getting error like object reference is not set to an instance of an object.

Please help if my syntax is correct or not.If not then please helpp!!

HI @Tabbu
How many column do you have and are you sure the index is 2 because index starts from 0
If you are mistaken change the index to (1) and try again

Regards
Sudharsan

Yeah i calculated from index 0 only

Okay ,So yor question is like you need to copy the value from Dt1 from column 2 and store that is Dt2 in the same column right?

Yess

You can try with filter data table → output Column and use index or Column name
image

And right range in 2 Column in excel

Regards
Sudharsan

@Tabbu

datatable2.Column(2)=datatable1.Column(2).ToString

Try as above

usually error object reference is not set appears if you are passing any null value

Hope this may help you

Thanks

@Tabbu are you validating Data table 1 col1 with Data table 2 col1?

One more doubt it will be datatable2.Columns(2) OR datatable2.Column(2)

Bcoz when i m using Column i m getting error

Example. DT1 col1 has the same value on Dt2 col1?
else you want to copy the vlaue DT1 col1 value to DT2 col1?

Hi!

Read 2 excels using read range and output as dt1 and dt2.

take one for each row and and mention your first dt.
take one assign and mention Column1=CurrentRow(“ColumnName”).tostring
take one more for each row and mention 2nd dt.
take one more assign Column2=CurrentRow1(“ColumnName”).tostring

in if

Coumn1=Column2

Regards,
NaNi

Not validating i m assign datatable1 value in datatable2

Use Columns

No Bro ,situation is not like this,there is some condition above and if that condition satisfied then i need to build one datatable2 and assign the value of datatable1 in datatable2

Yess that only i m using then too getting the error

If your condition is satisfied inside the Then block take one Build dt and mention the columns then use add data row inside the for each…

if not satisfied what you wants to perform?

Hey @Tabbu,

Can you please check below thread it will help you on what you want to achieve.

Thanks.

In add row activity how i provide in which column i need to paste this value?

In add data row inside the array of row just mention {Column1,Column2,Column3} so on…
before that you need to assign the values like below…

Add data row must be inside the for each row

and one more thing…

in your Build Data columns And add data row Array of rows must be the same order…

For example

In your Build Dt columns like → Column1 Column3 Column2 Column4
Array of row must follow->{Column1,Column3,Column2,Column4}

Regards,
NaNi