我遇到以下错误 无法启用此约束,因为并非所有值都有对应的父值. 代码是: 试试 DB.connectDB() 将Dim ds用作新数据集 Dim dt1作为DataTable = DB.selectRecord("SELECT tbl_Profile_View.ContractorID,COUNT(tbl_Profile_View.ContractorID)AS Profiles_View,realtygu_dbo.vwUserspName LoginName,realtygu_dbo.vwUsers.CompanyAddress,realtygu_dbo.vwUsers.PhoneNo.内联接realtygu_dbo.vw用户打开tbl_Profile_View.ContractorID = realtygu_dbo.vwUserspID GROUP BY tbl_Profile_View.ContractorID,realtygu_dbo.vwUserspName,realtygu_dbo.vwUsers.CompanyAddress,realtygu_dbo.vwUserProfile. ) Dim dTable1 As DataTable = dt1.Copy dTable1.TableName =父母" ds.Tables.Add(dTable1) Dim dt2作为DataTable = DB.selectRecord("SELECT tbl_Profile_View.ContractorID,COUNT(tbl_Profile_View.ContractorID)AS Profiles_View,realtygu_dbo.vwUserspName作为LoginName,realtygu_dbo.vwUsers.CompanyAddress,realtygu_dbo.vwUsers.Phone来自tbl_Profile_View的tbl_Profile_View.ClientID内联接realtygu_dbo.vw用户打开tbl_Profile_View.ClientID = realtygu_dbo.vwUserspID GROUP BY tbl_Profile_View. tbl_Profile_View.ClientID按tbl_Profile_View.ClientID升序排列) dTable dTable2为DataTable = dt2.Copy dTable2.TableName ="Child" ds.Tables.Add(dTable2) ds.Relations.Add("PK",ds.Tables(0).Columns("ContractorID"),ds.Tables(1).Columns("ContractorID")) ''ds.Tables(0).DefaultView.Sort ="InvoiceDate Desc" ViewState("ds")= ds hgProvider.DataSource = ds hgProvider.DataMember = ds.Tables(0).TableName hgProvider.DataBind() 异常捕获 Response.Write(ex.Message) 结束尝试 解决方法请帮帮我 谢谢您
i am getting following error This constraint cannot be enabled as not all values have corresponding parent values. the code is : Try DB.connectDB() Dim ds As New DataSet Dim dt1 As DataTable = DB.selectRecord("SELECT tbl_Profile_View.ContractorID, COUNT(tbl_Profile_View.ContractorID) AS Profiles_View, realtygu_dbo.vwUserspName LoginName, realtygu_dbo.vwUsers.CompanyAddress, realtygu_dbo.vwUsers.PhoneNo, realtygu_dbo.vwUsers.CompanyEmail FROM tbl_Profile_View INNER JOIN realtygu_dbo.vwUsers ON tbl_Profile_View.ContractorID = realtygu_dbo.vwUserspID GROUP BY tbl_Profile_View.ContractorID, realtygu_dbo.vwUserspName, realtygu_dbo.vwUsers.CompanyAddress, realtygu_dbo.vwUsers.PhoneNo, realtygu_dbo.vwUsers.CompanyEmail order by tbl_Profile_View.ContractorID asc") Dim dTable1 As DataTable = dt1.Copy dTable1.TableName = "Parent" ds.Tables.Add(dTable1) Dim dt2 As DataTable = DB.selectRecord("SELECT tbl_Profile_View.ContractorID, COUNT(tbl_Profile_View.ContractorID) AS Profiles_View, realtygu_dbo.vwUserspName as LoginName, realtygu_dbo.vwUsers.CompanyAddress, realtygu_dbo.vwUsers.PhoneNo, realtygu_dbo.vwUsers.CompanyEmail, tbl_Profile_View.ClientID FROM tbl_Profile_View INNER JOIN realtygu_dbo.vwUsers ON tbl_Profile_View.ClientID = realtygu_dbo.vwUserspID GROUP BY tbl_Profile_View.ContractorID, realtygu_dbo.vwUserspName, realtygu_dbo.vwUsers.CompanyAddress, realtygu_dbo.vwUsers.PhoneNo, realtygu_dbo.vwUsers.CompanyEmail, tbl_Profile_View.ClientID order by tbl_Profile_View.ClientID asc ") Dim dTable2 As DataTable = dt2.Copy dTable2.TableName = "Child" ds.Tables.Add(dTable2) ds.Relations.Add("PK", ds.Tables(0).Columns("ContractorID"), ds.Tables(1).Columns("ContractorID")) ''ds.Tables(0).DefaultView.Sort = "InvoiceDate Desc" ViewState("ds") = ds hgProvider.DataSource = ds hgProvider.DataMember = ds.Tables(0).TableName hgProvider.DataBind() Catch ex As Exception Response.Write(ex.Message) End Try how it is solve please help me thanks you
推荐答案您在此处创建了两个数据表(table1,table2). 并且在两个表中都有一些值,您可以从数据库中选择它们.. 您的表格中有一些数据会产生冲突..尝试消除两者之间的冲突.. 否则只需在代码中更改一行,然后尝试 You have created two data tables here(table1, table2). and in both table there is some values, which you are selecting from database.. In your table there is some data which is producing confliction.. Try to remove the conflict between both.. or else just change a line in your code and try ds.Relations.Add("FK", ds.Tables(0).Columns("ContractorID"), ds.Tables(1).Columns("ContractorID"))
最好的..:)
all the best.. :)
更多推荐
由于并非所有值都有对应的父值,因此无法启用此约束.
发布评论