Create and add data in DataTable using C#

Hello,

I want to create data table with string data type

Then, i want to add row using C#

e.g. there is an empty table created, the row are added as per IF condition

package name : packageA

any help

Thanks

@nikhil.chandre

can you please elaborate as for these tasks you have generate datatable activity and add data row

cheers

I want to create a empty dataTable say TestTable

then i want to add rows as per the IF condition

after that , I want to iterate the data table

@nikhil.chandre

use build datatable to create an empty datatable

inside if conditions on the side you want to add rows use add data row activity

then use for each row in datatable to interate over it

cheers

getting this error

language is C# in my project

image

give a try at
new object[]{var1,var2,....varn};

@nikhil.chandre,

Use this way.

image

Thanks,
Ashok :slight_smile:

in build data table , could we create empty data table

as for me its showing null

@nikhil.chandre,

Yes, we can.

Checkout this sample workflow.

Workflow.xaml (9.0 KB)

Thanks,
Ashok :slight_smile:

while executing getting this msg

Add Data Row: Object reference not set to an instance of an object.

@nikhil.chandre It means you didn’t configured the output property of the build datatable activity.

You should assign Datatable variable to it.

@nikhil.chandre

  1. In build datatable remove the extra row you show see only one that is the reason you are getting a null row
  2. In build datatable procide a datatable and use same in add data row

Cheers