Ok.... I have just figured out that the code used for the function I need is class.bindingsource.addnew(), took me awhile to figure that out lolz. but now I have a another problem I hope you guys can help me with. I keep getting an error message which has something to do with a foreign key constraint in the child table.
this error pops up when I click the savebutton, this is the code in the button click event
- Try
-
Me.Validate()
-
Me.PurchaseOrderBindingSource.EndEdit()
-
Me.PurchaseOrderTableAdapter.Update(Me.PurchaseOrderDataSet)
-
PurchaseOrderDetalPONumberTxt.Text = PurchaseOrderNumberTxt.Text
-
-
Catch ex As Exception
-
MessageBox.Show(ex.ToString)
-
End Try
-
Try
-
Me.PurchaseOrderDetailBindingSource.EndEdit()
-
Me.PurchaseOrderDetailTableAdapter.Update(Me.PurchaseOrderDataSet)
-
MessageBox.Show("Saved")
-
Catch ex As Exception
-
MessageBox.Show(ex.ToString)
-
End Try
any ideas why this is happening? I think it has something to do with the table setup in my data base. here is what the tables in my dataset are like
PurchaseOrder(Parent)
-PurchaseOrderID -PK
-Other Information
PurchaseOrderDetail(Child)
-PurchaseOrderDetailID - PK
-PurchasOrderID - FK relation to PurchaseOrderTable.PurchaseOrderID.PK
-Other Information
there are 2 other tables but i doubt that there are any problems in them.As you can see Im Trying to Update two tables at the same time and whenever i click the savebutton only the Purchase Order table saves and i can only save the Purchaseorderdetails table after the purchase Order is saved... please help me ^_^