System.Data.DuplicateNameException

  • Thread starter Thread starter H Branyan
  • Start date Start date
H

H Branyan

Please see this error below. This code runs fine in v1.0, but I just
compiled it and ran it in v1.1. The first time the page loads, everything is
OK, but if you hit refresh or navigate away and come back to the page, the
following error occurs:

A column named 'ORG' already belongs to this DataTable: cannot set a nested
table name to the same name.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.DuplicateNameException: A column named 'ORG'
already belongs to this DataTable: cannot set a nested table name to the
same name.

Source Error:
Line 115:
Line 116: DataRelation drel = new DataRelation("ORG_RECURSIVE",
ds.Tables["ORG"].Columns["Org_ID"],
ds.Tables["ORG"].Columns["Parent_Org_ID"]);
Line 117: drel.Nested = true; // this line throws error
Line 118: ds.Relations.Add( drel );
Line 119:

Stack Trace:

[DuplicateNameException: A column named 'ORG' already belongs to this
DataTable: cannot set a nested table name to the same name.]
System.Data.DataColumnCollection.RegisterName(String name, Object obj) +246
System.Data.DataRelation.set_Nested(Boolean value) +418
MERC.AircatWeb.Applications.NewUser.LoadTreeView() in
c:\hmb_aircat_dev\c130_aircat\aircat_web\applications\newuser.aspx.cs:117
MERC.AircatWeb.Applications.NewUser.Page_PreRender(Object sender, EventArgs
e) in
c:\hmb_aircat_dev\c130_aircat\aircat_web\applications\newuser.aspx.cs:76
System.Web.UI.Control.OnPreRender(EventArgs e) +67
System.Web.UI.Control.PreRenderRecursiveInternal() +62
System.Web.UI.Page.ProcessRequestMain() +1466

++++
I am not having any luck rewriting this code, so if anyone could help, I
would appreciate it. Thank you.
 
Please note: When the DataTable ("Org") is stored in Cache (or Session,
doesn't matter), the error occurs when refreshing the page i.e. the
DataTable is loaded from memory, not freshly created.

When I turn caching/session variable off and load the DataTable from the
database on each load, no error is ever thrown.

So 1) Storing the object in memory results in error.
2) .Net 1.1 breaks working code (ran fine in 1.0).
 
Back
Top