locked
Cannot add a column named 'serial': a nested table with the same name already belongs to this DataTable RRS feed

  • Question

  • User-1971168174 posted

    Hi ,

    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.

    Thanks!

    Monday, August 3, 2020 12:38 PM

Answers

  • User475983607 posted

    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...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 3, 2020 1:46 PM
  • User753101303 posted

    Hi,

    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).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 3, 2020 1:52 PM
  • User-1971168174 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 3, 2020 2:25 PM

All replies

  • User475983607 posted

    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...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 3, 2020 1:46 PM
  • User753101303 posted

    Hi,

    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).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 3, 2020 1:52 PM
  • User-1971168174 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 3, 2020 2:25 PM