I have a data entry form that has a command button on it with the following code;
Public Class frmCarriers
Private CallingForm As Object
Private Sub TblCarriersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.TblCarriersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.RootDBSQLDataSet)
End Sub
Private Sub frmCarriers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'RootDBSQLDataSet.tblCarriers' table. You can move, or remove it, as needed.
Me.TblCarriersTableAdapter.Fill(Me.RootDBSQLDataSet.tblCarriers)
Me.TblCarriersBindingSource.AddNew()
End Sub
Private Sub btnSaveExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveExit.Click
Me.TblCarriersBindingNavigatorSaveItem_Click(Nothing, Nothing)
frmCarriers_Load(Nothing, Nothing)
Dim myForm As Form
myForm = CallingForm 'my calling form
Me.Close()
myForm.Show()
End Sub
Public Sub New(ByVal caller As Object)
MyBase.New()
InitializeComponent()
' Note which form has called this one
CallingForm = caller
End Sub
It seems to work when the button is clicked except for the fact that after a period of time the new record that was added does not persist in the backend database. It is persent for awhile and then disapears. I am not sure if it is because the record is not being updated to the SQL backend and instead the dataset is being updated. ? Any help will be very much appreciated.
Public Class frmCarriers
Private CallingForm As Object
Private Sub TblCarriersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.TblCarriersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.RootDBSQLDataSet)
End Sub
Private Sub frmCarriers_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'RootDBSQLDataSet.tblCarriers' table. You can move, or remove it, as needed.
Me.TblCarriersTableAdapter.Fill(Me.RootDBSQLDataSet.tblCarriers)
Me.TblCarriersBindingSource.AddNew()
End Sub
Private Sub btnSaveExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveExit.Click
Me.TblCarriersBindingNavigatorSaveItem_Click(Nothing, Nothing)
frmCarriers_Load(Nothing, Nothing)
Dim myForm As Form
myForm = CallingForm 'my calling form
Me.Close()
myForm.Show()
End Sub
Public Sub New(ByVal caller As Object)
MyBase.New()
InitializeComponent()
' Note which form has called this one
CallingForm = caller
End Sub
It seems to work when the button is clicked except for the fact that after a period of time the new record that was added does not persist in the backend database. It is persent for awhile and then disapears. I am not sure if it is because the record is not being updated to the SQL backend and instead the dataset is being updated. ? Any help will be very much appreciated.