无法启用此约束,因为并非所有值都在c#中具有相应的父值?

编程入门 行业动态 更新时间:2024-10-25 18:33:00
本文介绍了无法启用此约束,因为并非所有值都在c#中具有相应的父值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试在嵌套的gridview中填充数据。我收到此错误无法启用此约束,因为并非所有值都具有相应的父值。我的错误是什么?帮帮我解决这个问题。 这是我的代码

I tried to populate data's in nested gridview. Am getting this error This constraint cannot be enabled as not all values have corresponding parent values. What is my error ? Help me to solve this. This is my code

validateDept.InitializeConnection(); OleDbConnection connection = new OleDbConnection(validateDept.connetionString); OleDbDataAdapter AdapterCustomers = new OleDbDataAdapter( "SELECT EmployeeId, FirstName FROM Employee", connection); OleDbDataAdapter AdapterInvoices = new OleDbDataAdapter( "SELECT InvoiceId, InvoiceNumber, InvoiceDate, SalesPerson AS EmployeeId, Customername AS CustomerId, (Select CustomerName from Customer where Customer.CustomerId = NewInvoice_1.CustomerName) AS Customer_Name, DueDate, Tax, GrandTotal, CompanyId, InvoiceStatus FROM NewInvoice_1", connection); DataSet dataSet11 = new DataSet(); //Create DataTable objects for representing database's tables AdapterCustomers.Fill(dataSet11, "Employee"); AdapterInvoices.Fill(dataSet11, "Invoices"); //Set up a master-detail relationship between the DataTables DataColumn keyColumn = dataSet11.Tables["Employee"].Columns["EmployeeId"]; DataColumn foreignKeyColumn = dataSet11.Tables["Invoices"].Columns["EmployeeId"]; dataSet11.Relations.Add("CustomerInvoice", keyColumn, foreignKeyColumn); // Getting error on this row //Bind the grid control to the data source gridControl1.DataSource = dataSet11.Tables["Employee"]; gridControl1.ForceInitialize(); //Assign a CardView to the relationship GridView cardView1 = new GridView(gridControl1); gridControl1.LevelTree.Nodes.Add("CustomerInvoice", cardView1); //Specify text to be displayed within detail tabs. cardView1.ViewCaption = "Invoice List of a Customer"; //Create columns for the detail pattern View cardView1.PopulateColumns(dataSet11.Tables["Invoices"]);

Thnakyou, Srihari

Thnakyou, Srihari

推荐答案

更多推荐

无法启用此约束,因为并非所有值都在c#中具有相应的父值?

本文发布于:2023-10-25 21:48:50,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:都在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!