# Error while using the data table argument in invoke code activity

**URL:** <https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978>\
**Category:** Activities\
**Tags:** invoke-code, datatable, question, system, activities\
**Created:** [November 30, 2021, 5:05pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978 "2021-11-30T17:05:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fresher](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Fresher](https://forum.uipath.com/u/Fresher)\
**Post date:** [November 30, 2021, 5:05pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978/1 "2021-11-30T17:05:24Z")

</div>

Hello,

Am trying to update the multiple rows from data table when it meets the specific condition. but am getting below error . Please assit.

SampleDt.Select(“Col1='”+value+“”).ToList().ForEach(Sub (row) row(“col2”=“test”))

SampleDt - argument (datatable - type in)  
value - argument (string - type in)

error : attached screenshot.

 ![image1](https://global.discourse-cdn.com/uipath/original/4X/d/1/6/d16699fed34984864f494b943f1be9270da099c5.png)

---

<div class="post-metadata">

**Author:** ![prasath\_S](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prasath_s/32/290219_2.png) [@prasath\_S](https://forum.uipath.com/u/prasath_S)\
**Post date:** [November 30, 2021, 5:13pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978/2 "2021-11-30T17:13:13Z")

</div>

Hi @Fresher

Please try below,

SampleDt.Select(“Col1=’”+value+“”).ToList().ForEach(Sub (row) row(“col2”)=“test”)

And also try changing the argument from in to in/out.

Thanks

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [November 30, 2021, 5:26pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978/3 "2021-11-30T17:26:09Z")

</div>

[How to Update Data Column Values of a Data Table | Community Blog](https://www.uipath.com/community/rpa-community-blog/options-for-updating-data-table-column-values)

it is listing your case

---

<div class="post-metadata">

**Author:** ![Fresher](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@Fresher](https://forum.uipath.com/u/Fresher)\
**Post date:** [November 30, 2021, 5:47pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978/4 "2021-11-30T17:47:39Z")

</div>

Hello @ppr - Thanks for the link, its really useful one!!

dtData.AsEnumerable.Where(Function (x) x(“TEAM”).ToString().Trim().StartsWith(teamFilter)).ToList

this expression will solve my query by adding the for each row activity, However could you please help to build the vb code using the invoke code activity.

@prasath_S - Thanks for your input, with that complier error is gone and but am getting target invocation error and am sure all the argument has the proper value in it.

Would be grateful if you can share some sample xaml to cross verify with mine.

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [November 30, 2021, 5:54pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978/5 "2021-11-30T17:54:09Z")

</div>

it’s just about mirroring the same to the invoke code

```auto
For Each row As Datarow In dt.AsEnumerable.Where(Function (x) x("Col1").toString.Equals(myValue).toList
    row("col2") = "test" 
Next

```

In LINQ you need to use the Where operator to do the filtering

> [@\[HowTo\] - First Start with LINQ (VB.Net)](https://forum.uipath.com/t/howto-first-start-with-linq-vb-net/318964):
>
> LINQ is part of the .NET framework and offers capabilities for interacting with data, objects or other sources within a particular syntax. This HowTo introduces on starting with LINQ (Language-Integrated Query). Current Version of this topic is DRAFT and will be finalized / enhanced soon Introduction Typical tasks for implementing parts of an automation project are interacting with e.g. with data in a datatable or items from collections. LINQ can help to implement it into a compact and standa…

About the arguments just respect datatype and directions  
Avoid that parameter/argument name is the same as the variable  
Avoid names similar to class names, method names or other Keywords

working with the Select method have a clear handling of the string surrounding ’

`SampleDt.Select("Col1='<-"+value+"->').ToList().ForEach(Sub (row) row("col2") = "test")`

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [December 3, 2021, 5:54pm UTC](https://forum.uipath.com/t/error-while-using-the-data-table-argument-in-invoke-code-activity/365978/6 "2021-12-03T17:54:48Z")

</div>

Closed on December 3, 2021, 5:54pm UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
