# Cannot create table in Invoke Code Activity

**URL:** <https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [June 22, 2021, 7:09am UTC](https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384 "2021-06-22T07:09:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![WASEEM\_KHAN](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/waseem_khan/32/195868_2.png) [@WASEEM\_KHAN](https://forum.uipath.com/u/WASEEM_KHAN)\
**Post date:** [June 22, 2021, 7:09am UTC](https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384/1 "2021-06-22T07:09:07Z")

</div>

Hi,

I want to create a data table inside invoke code activity but I am getting error

“Invoke code: Exception has been thrown by the target of an invocation.”

Here are my code and arguments inside invoke activity:

 ![aa](https://global.discourse-cdn.com/uipath/original/3X/d/3/d363a04cdc2a3f104937da887e2f562130ee9c65.png)  
 ![bb](https://global.discourse-cdn.com/uipath/original/3X/e/c/ec0708b8fcf471b8bbfc64eb4acee869e9703b4f.png)

Any help in this regard?

Best,  
Waseem khan

---

<div class="post-metadata">

**Author:** ![Yoichi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/yoichi/32/523754_2.png) [@Yoichi](https://forum.uipath.com/u/Yoichi)\
**Post date:** [June 22, 2021, 10:23am UTC](https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384/2 "2021-06-22T10:23:07Z")

</div>

Hi,

First, can you check details of exception from $exceptionDetails at LocalsPanel?

If it’s null reference exception, can you modify Out to In at Direction of dtOrig in ArgumentPanel?  
(If dt\_test is already created before then)

Or add the following at the first line.

```
Dim dtOrig As DataTable = New DataTable()

```

Regards,

---

<div class="post-metadata">

**Author:** ![ermanoj3101](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ermanoj3101/32/232005_2.png) [@ermanoj3101](https://forum.uipath.com/u/ermanoj3101)\
**Post date:** [June 22, 2021, 10:27am UTC](https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384/3 "2021-06-22T10:27:58Z")

</div>

Hi,

Try to make variable as In/Out and don’t forget to initialize data table as “New DataTable”

---

<div class="post-metadata">

**Author:** ![WASEEM\_KHAN](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/waseem_khan/32/195868_2.png) [@WASEEM\_KHAN](https://forum.uipath.com/u/WASEEM_KHAN)\
**Post date:** [June 22, 2021, 11:18am UTC](https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384/4 "2021-06-22T11:18:53Z")

</div>

> [@Yoichi](#):
>
> `Dim dtOrig As DataTable = New DataTable()`

Thanks for your feedback. I can only see variables and arguments:

 ![aa](https://global.discourse-cdn.com/uipath/original/3X/c/8/c8382e50b9fddbed45e0e47fda2e948be78e6817.png)

From where can I check exceptionDetails?

---

<div class="post-metadata">

**Author:** ![WASEEM\_KHAN](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/waseem_khan/32/195868_2.png) [@WASEEM\_KHAN](https://forum.uipath.com/u/WASEEM_KHAN)\
**Post date:** [June 22, 2021, 11:29am UTC](https://forum.uipath.com/t/cannot-create-table-in-invoke-code-activity/324384/5 "2021-06-22T11:29:51Z")

</div>

The error is gone if I write create datatable at the very start of code : Dim dtOrig As DataTable = New DataTable()  
But there is another problem. I want to copy a filled datatable to this newly created datatable. The filled datatable is dt\_tempSql and it has same column names. I do not know, how to specify arguments in this case? I want to insert dtOrig into sql server afterwards.  
 ![bb](https://global.discourse-cdn.com/uipath/original/3X/a/9/a973d117d71b791cd0904d588f5a8e0f39508fc2.png)
