Remove duplicate database error

Hello,

I need to remove some duplicate raw from a data table and I use the following code:

dt=dt.DefaultView.ToTable(True,{“Column1”,“Column2”,“Column3”,“Column4”})

but I get the exception " A column named ‘Column4’ already belongs to this DataTable"

Someone knows how to fix this?

thank you

Hi,
Is it possible to attach the xml, to check the error. Because I have verified it . It is working well.

Hi @Siltra,

Refer this post

DataTable filtering with expressions

Regards,
Arivu

Can you try this.without curly braces

dt=dt.DefaultView.ToTable(True,“Column1”,“Column2”,“Column3”,“Column4”)

Thank you for your answer. I think I can to resolve it using dt=dt.DefaultView.ToTable(True) because I’m working with the entire data table.

The problem now is that I have two equal rows that differ only for one space and robot can’t recognize it.
There is a way to remove all spaces from the entire table?

Thank you again for your support

:+1:

you should not remove all the empty space, you need to remove at the end only
try like this
((From LineNo In dt.DefaultView.ToTable(True,"Product").Select().ToList() Select (From row In dt.Select Where row("Product").ToString.Trim=LineNo("Product").ToString.Trim Select row).ToList(0)).ToList()).CopyToDatatable()