Understanding the Difference

can anyone help on the Error
(From name As DataColumn In Excel_DT.Columns
select name.ColumnName
).ToArray()

1 Like

Hi @devasaiprasad_K ,

Could you maybe try removing the As DataColumn and check if it works ?

1 Like

Hi @devasaiprasad_K

You have made a small mistake in your linq expression, Change the linq as below,

(From row In dt1.Columns
Select row
	).ToArray

Hope it helps!!

1 Like

1 Like
(From name In Excel_DT.Columns
Select name
	).ToArray

Try this one… @devasaiprasad_K

1 Like

nope some conversion Error

1 Like

Do you want to store the column names in datatable in array right.

The Variable which is in the assign activity is Array of String.

If above will not work, then share the error you are getting… @devasaiprasad_K

1 Like

i want to print the Datacolumn names and hence trying to store into an Array and print array Values

1 Like

Hi @devasaiprasad_K

columnNames should of type arrayof string.
Excel_DT is your datatable

string[] columnNames = (from DataColumn name in Excel_DT.Columns
                        select name.ColumnName).ToArray()
1 Like

1 Like

Okay @devasaiprasad_K

→ Take an assign activity and create a Array of Object datatype variable called Arr_Columns.
→ In the other side of assign activity give the below linq expression,

- Assign -> Arr_Columns = (From name In Excel_DT.Columns
                          Select name
                                	).ToArray

→ Then you can use the for each activity to loop through the Arr_Columns variable, inside for each insert write line activity to print each item in output panel.

Check the below workflow for better understanding,

Output in Output Panel -
image

Hope it helps!!

1 Like

image

am i missing something

1 Like

@devasaiprasad_K

Change datatype of ColName1 array of object

HI @devasaiprasad_K

Please change the columnName1 to array of object type

Regards

1 Like

thanks for the solution, it worked…

1 Like

It’s my pleasure… @devasaiprasad_K

Happy Automation!!

Hi @devasaiprasad_K

You are over complicating things,
What you can do is just create a variable of type DataColumnCollection, and assign DtName.Columns
You’ll get the whole list of column names in there.

Sample Workflow:

GetDataColumnNames.xaml (9.9 KB)

Screenshot:


Thanks
Happy Automation!

1 Like

Hi Executed the above code… simply superb.

Thanks a lot… for pitching in

1 Like

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