Private Sub TblContactsBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblContactsBindingNavigatorSaveItem.Click Dim newMemberRow As DataRow 'To create a new row in the tblMember table Dim contactID As Integer 'To hold the contactID to insert in the new member ContactID field Dim rowsaffected As Integer 'To indicate the number of rows affected by update Dim contactIndex As Integer Me.Validate() Me.TblContactsBindingSource.EndEdit() Me.TblContactsTableAdapter.Update(Ds.tblContacts) ' Me.TblContactsBindingSource.MoveLast() contactIndex = Me.TblContactsBindingSource.Position() MessageBox.Show("The contact Index is " & contactIndex) contactID = Me.Ds.Tables("tblContacts").Rows(contactIndex).Item("ContactID") Me.TblContactsBindingSource.ResetBindings(True) If (Me.TblMemberBindingSource.Find("ContactID", contactID.ToString()) < 0) Then MessageBox.Show("Current Position in table " & TblMemberBindingSource.Position().ToString()) MessageBox.Show("The ContactID is " & contactID.ToString()) ' newMemberRow = Ds.Tables("tblMember").NewRow() ' newMemberRow.Item("ContactID") = contactID ' newMemberRow.Item("Status") = StatusTextBox.Text ' newMemberRow.Item("MemberNotes") = MemberNotesTextBox.Text Try Ds.Tables("tblMember").Rows.Add(newMemberRow) Me.Validate() Me.TblMemberBindingSource.EndEdit() Me.TblMemberTableAdapter.Update(Ds.tblMember) Catch ex As Exception MessageBox.Show(ex.Message) End Try ElseIf (Me.TblMemberBindingSource.Find("ContactID", contactID.ToString()) >= 0) Then TblMemberBindingSource.MoveFirst() Try Me.TblMemberBindingSource.EndEdit() Catch ex As Exception MessageBox.Show(ex.Message) End Try End If 'Me.TableAdapterManager.UpdateAll(Me.Ds) End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)