Data base master/detail consistency

Steve36445

Well-known member
Joined
Dec 23, 2007
Messages
58
Programming Experience
10+
Can you help me please?

In it's simplest form, I have two forms a master form and a detail form.

I added the data source from within the ide.

Data> add new data source
database>new connection > microsoft sql server database file.
Selected table etc.

From the datasources tab in the ide I

dragged the grid view onto the master form.
dragged the detail view onto the details form.

Independently both forms work fine, However if I load the master form first and then load the detail form when the master dgv is clicked the problems start.


Master form

VB.NET:
  Private Sub Outing_tableDataGridView_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Outing_tableDataGridView.CellClick
        Dim current_row As Int16 = Outing_tableDataGridView.CurrentCell.RowIndex
        current_outing_id = Val(Outing_tableDataGridView(0, current_row).Value)
        current_outing_title = Outing_tableDataGridView(1, current_row).Value
        detail_form.ShowDialog()

    End Sub

detail form

VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Outing_tableTableAdapter.Fill(Me.Ramble_plannerDataSet.outing_table)
        Me.KeyPreview = True
        Outing_tableBindingSource.Filter = "outing_id = " + current_outing_id.ToString
    End Sub

All variables are correctly declared and the details form works fine, the correct record comes up and can be added, edited and deleted.

I then save the form by clicking on the save icon and close the form but changes made to the details form (e.g. additions or deletions) are NOT reflected on the master form until I close and rerun the application.

I guess it's just a matter of refreshing the right control(s) on the master form but I cant seem to find it. Any Ideas?

Thanks,

Steve
 
The problem is that your two forms both have independent copies of the data, so changing one doesn't affect the other. What you should do is pass the data from the master form to the detail form, so there's only one copy of the data and any changes are reflected all round.
 
Back
Top