Question Frustrated Parent Child Insert

dsk96m

Well-known member
Joined
Jan 11, 2013
Messages
173
Programming Experience
1-3
I have received alot of help from this site on this issue. I have solved a lot of my problems and I am down to one final one. I have a parent table with two child tables. the parent id is in each of the child tables. On save, the id is flowed down to the child tables with no problems. The problem is when i save, the parent table is inserted into the sql server db, but the child tables are not, they remain as -1. Not sure why they arent saving. Here is my code:

VB.NET:
    Private Sub FlightcardBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles FlightcardBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.FlightcardBindingSource.EndEdit()
        Me.System_setupBindingSource.EndEdit()
        Me.Aircraft_conditionBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.FlightTestApp2DataSet)
    End Sub

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.SpeedTableAdapter.Fill(Me.FlightTestApp2DataSet.speed)
        Me.AltitudeTableAdapter.Fill(Me.FlightTestApp2DataSet.altitude)
        Me.AntennatiltTableAdapter.Fill(Me.FlightTestApp2DataSet.antennatilt)
        Me.AntennapositionTableAdapter.Fill(Me.FlightTestApp2DataSet.antennaposition)
        Me.ModetypeTableAdapter.Fill(Me.FlightTestApp2DataSet.modetype)
        Me.Aircraft_conditionTableAdapter.Fill(Me.FlightTestApp2DataSet.aircraft_condition)
        Me.System_setupTableAdapter.Fill(Me.FlightTestApp2DataSet.system_setup)
        Me.FlightcardTableAdapter.Fill(Me.FlightTestApp2DataSet.flightcard)
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.System_setupBindingSource.AddNew()
        Me.Aircraft_conditionBindingSource.AddNew()
        Me.FlightcardBindingSource.EndEdit()
    End Sub
 
This thread can be deleted. It ended up being my dataset was messed up. I deleted the dataset and recreated it. It is working now.
 
Ok, still having this issue. I have a parent table and several child tables. On save two of the child tables are saving to the database correctly. Two others are not. The parent id is flowing down, but the child table is not saving to the database. I am doing the same things for the two that arent working that I am doing for the two that are working. There are foreign keys in the database and they are set to cascade. I have also set the dataset to the same. I checked the tables that are working with the ones that aren't and they seem to be the same. Can't figure out why the two are working and the other two child tables arent saving.
 
Again, nevermind. It was the stupid tableadaptermanager. For the tables it wasnt working on, it had (none) in the selection.
 
Back
Top