I am trying to setup a relationship between 2 tables from an access database but what I have done throws up an error at the part of my code where I set up the relatonship.
Below is my code and my error on line 13 to 15 says - This constraint cannot be enabled as not all values have corresponding parent values.
Any ideas?
[CODE=.VBNET]
Public Sub Retrieve()
objDS.Clear()
objCustomerDA.F illSchema(objDS , SchemaType.Sour ce, "CustomerDetail s")
objCustomerDA.F ill(objDS, "Customer Details")
objAccountsDA.F illSchema(objDS , SchemaType.Sour ce, "CustomerAccoun ts")
objAccountsDA.F ill(objDS, "CustomerAccoun ts")
objDS.Relations .Clear()
objDS.Relations .Add("CustomerA ccounts2Custome rDetails", _
objDS.Tables("C ustomerDetails" ).Columns("Cust omerID"), _
objDS.Tables("C ustomerAccounts ").Columns("Cus tomerID"))
cboAccounts.Ite ms.Clear()
Dim i As Integer, strCurrentID As String
For i = 1 To objDS.Tables("C ustomerDetails" ).Rows.Count
strCurrentID = objDS.Tables("C ustomerDetails" ).Rows(i - 1).Item("Custom erID")
cboAccounts.Ite ms.Add(strCurre ntID)
Next
cboAccounts.Sel ectedIndex = 0
FillCustomerDet ails()
FillCustomerAcc ounts()
End Sub
[/CODE]
Below is my code and my error on line 13 to 15 says - This constraint cannot be enabled as not all values have corresponding parent values.
Any ideas?
[CODE=.VBNET]
Public Sub Retrieve()
objDS.Clear()
objCustomerDA.F illSchema(objDS , SchemaType.Sour ce, "CustomerDetail s")
objCustomerDA.F ill(objDS, "Customer Details")
objAccountsDA.F illSchema(objDS , SchemaType.Sour ce, "CustomerAccoun ts")
objAccountsDA.F ill(objDS, "CustomerAccoun ts")
objDS.Relations .Clear()
objDS.Relations .Add("CustomerA ccounts2Custome rDetails", _
objDS.Tables("C ustomerDetails" ).Columns("Cust omerID"), _
objDS.Tables("C ustomerAccounts ").Columns("Cus tomerID"))
cboAccounts.Ite ms.Clear()
Dim i As Integer, strCurrentID As String
For i = 1 To objDS.Tables("C ustomerDetails" ).Rows.Count
strCurrentID = objDS.Tables("C ustomerDetails" ).Rows(i - 1).Item("Custom erID")
cboAccounts.Ite ms.Add(strCurre ntID)
Next
cboAccounts.Sel ectedIndex = 0
FillCustomerDet ails()
FillCustomerAcc ounts()
End Sub
[/CODE]
Comment