System.Data.DuplicateNameException

Hi ! RPA team

Please give me the solution for this @aksh1yadav @balupad14 @sara_s

RemoteException wrapping System.Data.DuplicateNameException: A column named 'Type ’ already belongs to this DataTable.
at System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column)
at System.Data.DataColumnCollection.BaseAdd(DataColumn column)
at System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column)
at UiPath.Core.Activities.AddDataColumn`1.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

image

@Selva_murugan

Could you please tell more details about the issue and what are you trying to do ?

@Selva_murugan
as exception said you add Type column via AddDataColumn in Datatable more then one times.
column name must be unique in datatable.
please look on code where you add column name in foreach statement

Thanks

hello @Selva_murugan

Above problem happening due to duplicate column name.

means table is already contains a column called "Type " and your trying add column with same name.

one more suggestion if your reading an excel, try to un-check the Add header property if you don’t want to add column names to your data table and also if column name or not unique.

check Add header property only when column names in the excel are unique.

Regards
Ajay

hello @Selva_murugan

the name of the column you put in Adddatacolumn or addtocollection Activity is dynamic or hardcode.please provide property window for same

Thanks

image

@Ajju @sandeep13 @lakshman @sara_s

the above is for add data column

@Selva_murugan

might document contains "Type " more than once, try to avoid the duplicate string in the Word document

I’m iterating through multiple files … In that each file it has type

But how to resolve that

@Selva_murugan

Add the column names at the beginning means only for the first document , for remaining documents Do Add rows only .

1 Like

How to give an condition when u r iterating through files like only for first file do this @ajju

@Selva_murugan

use a counter ,initialize it to 1 at the beginning for the first file after reading the first file just increment it to some number.

put a condition if (counter >1 ){
don’t add the header ;
}
else { ////if counter is 1 then add header
add the header ;
counter = 1000;
}

It’s not working buddy