开发者

circular reference in self-nested table 'firstname1'. asp.net

开发者 https://www.devze.com 2023-02-25 08:25 出处:网络
This is the error i am getting \"circular reference in self-nested table \'firstname1\'\". I want to Hierarchical Data binding. Employee and their supervisor are in the same table.

This is the error i am getting "circular reference in self-nested table 'firstname1'".

I want to Hierarchical Data binding. Employee and their supervisor are in the same table.

I am taking reference from http://weblogs.asp.net/alessandro/archive/2008/03/01/part-2-building-and-binding-hierarchical-data-from-the-database-to-the-asp-net-navigation-controls.aspx.

But it is giving error on generating Xml.

using (SqlConnection con = new SqlConnection(WebConf开发者_开发问答igurationManager.ConnectionStrings["RMSConnection"].ToString()))
{
    string SqlCommand = "SELECT EmployeeId,FirstName,ReportToId FROM tblEmployee";
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(
    SqlCommand, con);
    adapter.Fill(ds);
    ds.Tables[0].TableName = "FirstName1";
    DataRelation dr = new DataRelation("pageId_parentId",ds.Tables["FirstName1"].Columns["EmployeeId"], ds.Tables["FirstName1"].Columns["ReportToId"]);
    dr.Nested = true;

    ds.Relations.Add(dr);
} 
//string s= ds.GetXml();    

above is my code. Please Suggest.

circular reference in self-nested table 'firstname1'. asp.net


You got an infinite loop in your table's data. You are trying to make a link between EmployeeId and ReportToId but something is wrong.

Your problem is with all your row where the EmployeeId is equal to ReportToId

Exemple:

EmployeeId   First Name   ReportToId
1            Super        1

In all those cases, you need to set the ReportToId to Null

EmployeeId   First Name   ReportToId
1            Super        Null
0

精彩评论

暂无评论...
验证码 换一张
取 消