Last post Aug 03, 2020 02:25 PM by neerajkumarmodi
Aug 03, 2020 12:38 PM|neerajkumarmodi|LINK
I am trying to add missing columns for each datatable in dataset, but its giving error Cannot add a column named 'serial': a nested table with the same name already belongs to this DataTable.
Please help me know if anyone can guess whats wrong.
Aug 03, 2020 01:46 PM|mgebhard|LINK
The error is very clear. The table already has a column named "serial". Fix your code so the logic cannot add duplicate columns. That might mean adding an index to the column name. Or it might mean there is a bug in the design that should get fixed.
You have to understand, the community cannot provide meaningful assistance without code that reproduces the issue. It is your responsibility to provide the community with code we can run to achieve the same issue. That does not mean post all your code.
Make an effort to target the problem. All I'm asking you to do is basic debugging and troubleshooting that every developer has to do...
Aug 03, 2020 01:52 PM|PatriceSc|LINK
And your dataset is loaded from an XML file? Never seen that by my understanding is that you likely loaded hierarchical data which are preserved by ADO.NET and that you are now trying to create a column with the same tag name to create a fk column. Do you
you have <serial> tag names in your XML file?
Edit: maybe related to https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/dataset-datatable-dataview/nesting-datarelations
I would have to try or provide perhaps the smallest possible XML file that would show the problem (I'm not using DataSets since long and don't remember to ever had or even heard about this feature).
Aug 03, 2020 02:25 PM|neerajkumarmodi|LINK
Thanks for Reply! and Sorry for not able to provide details.
Somehow table does not have column name as serial, but in the dataset another datatable was there with the name serial(nt sure if this caused the error).
It worked When I tried adding the same column with name serial after coping it to another table.
DataTable dt_1 = dt.Copy();
now if i ad the serial column it works.