J
Jay
I have created a form from the data sources that is generated by a wizard to
produce a dataset. Now I just simply drag tables from this dataset to my
winforms. I can have two tables in winform with a parent/child form.
The binding navigator will create a code below to save the data back to the
database:
Me.Validate()
Me.InvoiceBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.InvoiceDataSet)
InvoiceDataSet includes two tables called Invoice and InvoiceDetails.
Beside from this code I also added a code below to update ItemsDetails
table.
ExecNonQuery("UPDATE ItemsDetails SET QtyOnHand = " & QtyOnHand - QtyOrdered
& " WHERE ItemDetailID = " & intItemDetailID)
Final code of btnSave_Click event:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Me.Validate()
Me.InvoiceBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.InvoiceDataSet)
ExecNonQuery("UPDATE ItemsDetails SET QtyOnHand = " &
QtyOnHand - QtyOrdered & " WHERE ItemDetailID = " & intItemDetailID)
End Sub
Sometimes ExecNonQuery will return an error and I want to rollback all
changes made to the InvoiceDataSet also.
Additionally here's the code in my form load event generated by the wizard:
Private Sub frmInvoice_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.InvoiceTableAdapter.Fill(Me.InvoiceDataSet.Invoice)
Me.InvoiceDetailsTableAdapter.Fill(Me.InvoiceDataSet.InvoiceDetails)
End Sub
Now, how can I add BeginTrans, RollbackTrans, and CommitTrans?
Thanks in advance
produce a dataset. Now I just simply drag tables from this dataset to my
winforms. I can have two tables in winform with a parent/child form.
The binding navigator will create a code below to save the data back to the
database:
Me.Validate()
Me.InvoiceBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.InvoiceDataSet)
InvoiceDataSet includes two tables called Invoice and InvoiceDetails.
Beside from this code I also added a code below to update ItemsDetails
table.
ExecNonQuery("UPDATE ItemsDetails SET QtyOnHand = " & QtyOnHand - QtyOrdered
& " WHERE ItemDetailID = " & intItemDetailID)
Final code of btnSave_Click event:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
Me.Validate()
Me.InvoiceBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.InvoiceDataSet)
ExecNonQuery("UPDATE ItemsDetails SET QtyOnHand = " &
QtyOnHand - QtyOrdered & " WHERE ItemDetailID = " & intItemDetailID)
End Sub
Sometimes ExecNonQuery will return an error and I want to rollback all
changes made to the InvoiceDataSet also.
Additionally here's the code in my form load event generated by the wizard:
Private Sub frmInvoice_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.InvoiceTableAdapter.Fill(Me.InvoiceDataSet.Invoice)
Me.InvoiceDetailsTableAdapter.Fill(Me.InvoiceDataSet.InvoiceDetails)
End Sub
Now, how can I add BeginTrans, RollbackTrans, and CommitTrans?
Thanks in advance