So i have a form that I am using databinding on for my main table, but during the save, I need to be able to insert into another table values of the primary key. Basically here are my tables:
Flightplan (Main) Table
id - primary key
flightid
flightdate
...
chargeID
FlightCharge Table
id
flightid
chargeid
Charge Table
id - primary key
chargenumber
description
So my form is creating a new flight. A flight can have multiple charges and charges can have multiple flights, so i have the go between table. In my form, they put in the information for the flight (flightid,flightdate, etc), they select the charges they want associated with the flight and then save. Obviously the primary key of the flight doesnt exist yet, so i was planning on doing:
Me.Validate()
Me.FlightplanBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.FlightTestAppDataSet)
Then getting the primary key of the newly inserted row and then inserting that and the charge id into the gobetween table. Is this the right way, and if it is how do I get the primary key of the newly inserted row? It is an autoincrement primary key.
If this isnt the right way to do it, what is a better way of doing it. I used the datasource wizard to create the dataset.
Flightplan (Main) Table
id - primary key
flightid
flightdate
...
chargeID
FlightCharge Table
id
flightid
chargeid
Charge Table
id - primary key
chargenumber
description
So my form is creating a new flight. A flight can have multiple charges and charges can have multiple flights, so i have the go between table. In my form, they put in the information for the flight (flightid,flightdate, etc), they select the charges they want associated with the flight and then save. Obviously the primary key of the flight doesnt exist yet, so i was planning on doing:
Me.Validate()
Me.FlightplanBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.FlightTestAppDataSet)
Then getting the primary key of the newly inserted row and then inserting that and the charge id into the gobetween table. Is this the right way, and if it is how do I get the primary key of the newly inserted row? It is an autoincrement primary key.
If this isnt the right way to do it, what is a better way of doing it. I used the datasource wizard to create the dataset.