Add Data Column: A column named 'keyword' already belongs to this DataTable. while it is in for loop

Add Data Column: A column named ‘keyword’ already belongs to this DataTable. while it is in for loop .i used clear data table also after one itteration
add data column activity

clear data table

Hi @LOHITH_KUMAR_SAKA

This error will occur when there is keyword column in the datatable.

Hope it helps!!

Hi @LOHITH_KUMAR_SAKA

You might be adding the column to same data table variable and also you are using the loop also for the same data table variable.so try adding the column to one data table variable and loop the data table using the other variable.

For that assign as below

dt1 = dt

Regards

@LOHITH_KUMAR_SAKA
Check if Column Exists: Before adding the ‘keyword’ column, check if it already exists in the DataTable. If it does, you can either skip the addition or take some other action based on your requirements.

Here is an example of how you can check if the column exists:

If Not dt.Columns.Contains("keyword") Then
    dt.Columns.Add("keyword", GetType(String))
End If

Hi @LOHITH_KUMAR_SAKA - Clear data table will not delete the columns. It deletes all rows from your data table.
you can see the below example.