I am working on a school project but I am getting an error when I attempt to save an altered dataset.
This is my code
Public Class KarateMembers Private mstrFilterStatus As String Private mstrDate As String Private Sub MembersBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Me.Validate() Me.MembersBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.KarateDataSet) End Sub Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'KarateDataSet.Members' table. You can move, or remove it, as needed. Me.MembersTableAdapter.Fill(Me.KarateDataSet.Members) radBefore.Checked = True End Sub Private Sub dtpFilterDate_TextChanged(sender As Object, e As System.EventArgs) Handles dtpFilterDate.TextChanged mstrDate = dtpFilterDate.Text filterGrid() End Sub Private Sub filterGrid() Select Case mstrFilterStatus Case "before" MembersTableAdapter.JoinedBefore(KarateDataSet.Members, mstrDate) Case "after" MembersTableAdapter.JoinedAfter(KarateDataSet.Members, mstrDate) Case Else MembersTableAdapter.Fill(KarateDataSet.Members) End Select End Sub Private Sub radAfter_CheckedChanged(sender As Object, e As System.EventArgs) Handles radAfter.CheckedChanged, radBefore.CheckedChanged Dim radRadioSelection = CType(sender, RadioButton) If radRadioSelection.Name = "radBefore" Then mstrFilterStatus = "before" Else mstrFilterStatus = "after" End If filterGrid() End Sub Private Sub btnSearchMembers_Click(sender As System.Object, e As System.EventArgs) Handles btnSearchMembers.Click Dim frmNewSearch As New frmNameFilter frmNewSearch.ShowDialog() End Sub Private Sub mnuSave_Click(sender As Object, e As System.EventArgs) Handles mnuSave.Click MembersTableAdapter.Update(KarateDataSet.Members) End Sub End Class
And this is the error that I'm getting:
The DELETE statement conflicted with the REFERENCE constraint "FK_Payments_Members". The conflict occurred in database "C:\USERS\JEREMY\PROGRAMMING\VB\FALL_2011\CLOUTIER_CH4_KARATEMEMBERS\CLOUTIER_CH4_KARATEMEMBERS\BIN\DEBUG\KARATE.MDF", table "dbo.Payments", column 'Member_Id'. The statement has been terminated.
I have done some research and I believe that this error has to do with the primary key having a relationship with the payments table. Something that I read said that you need to enable cascading deletes but I can't figure out how or even if that is the correct thing to do.
This post has been edited by JeremyC: 13 October 2011 - 01:35 PM