1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
Dim relation As DataRelation
relation = New DataRelation("relationAchat", achatDataSet.Tables("Achat").Columns("IDAchat"), achatDataSet.Tables("AchatDetail").Columns("IDAchat"))
Try
relation.ChildKeyConstraint.DeleteRule = Rule.Cascade
relation.ChildKeyConstraint.UpdateRule = Rule.Cascade
achatDataSet.Relations.Add(relation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "relation entre Achat et AchatDetail")
End Try
le message de l'exception:
Object reference not set to an instance of an object
voici le code:
Dim achatSQL As String = "select *from Achat"
Dim achatDetailSQL As String = "select *from AchatDetail"
Dim achatDataSet As New DataSet
Dim achatTableAdapter As SqlDataAdapter
Dim achatDetailTableAdapter As SqlDataAdapter
Dim relation As DataRelation
achatDataSet = New DataSet("orderDataSet")
achatTableAdapter = New SqlDataAdapter(achatSQL, con)
achatDetailTableAdapter = New SqlDataAdapter(achatDetailSQL, con)
achatTableAdapter.Fill(achatDataSet, "Achat")
achatDetailTableAdapter.Fill(achatDataSet, "AchatDetail") |
Partager