Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: FOREIGN KEYS SUCK


Message #1 by "mike" <MIKEZCG@y...> on Wed, 8 Jan 2003 00:00:48
Here is the problem:


Private Sub addFkey()
        With ds.Tables("Coa")
            .Constraints.Add("fkCOAVend", _
            .Columns("pkCoa"), _
            ds.Tables("Vendors").Columns("DfltAcct"))  'overload4
        End With
    End Sub

The signature that my VS.NET shows me is : 
.constrints.add(name, primarykeycol,foreignkeycol)
IS THE PRIMARYKEY COL IN THE SIGNATURE IN THE PARENT TABLE?? 

in my code above the primary key of the with table is pkCOa   the other 
table is vendors  the msg below seems to be telling me i have these col 
backward :

this constriant cannot be added since foreignkeydoesnt belong to table 
coa. 

so i switch them  ...

With ds.Tables("Coa")
 .Constraints.Add( _
          "fkCOAVend", _
          ds.Tables("Vendors").Columns("DfltAcct"), _
          .Columns("pk"))  'overload4
End With

my new msg is :

this constraint cannot be enabled as not all values have  corresponding 
parent values


this i dont think can be true i have 3 god dam records in the ()%@#$()% 
table?  I have now wasted 1 week on this ONE )*(& line of code. PLEASE can 
SOMEONE HELP ME WITH THIS?  

Please provide a full explanatin of fkeys in ado.net i wasted 1 full week 
on this and im sure i lost my bonus damn it.

M~


Mike Kerr

  Return to Index