关闭我的应用程序然后重新启动

时间:2017-02-24 14:18:33

标签: sql vb.net datagridview bindingsource

我一直在努力解决问题,我已经尝试了一切。关于堆栈溢出有类似的问题,但我已经厌倦了所有解决方案,它们都没有为我工作。问题是在调用数据源绑定后,更改未存储在数据库文件中。下面是保存按钮的代码片段

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

    If isValidData() = True Then ' sub routine that checks data inputted into textboxes is valid.
        Try
            ' i get data from the textboxes on form which are binded to the bindingsource viewplanet... 
            Me.ViewPlanetAlliancesBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.DsLab4)
            MessageBox.Show("Successfully Saved Data Row")
            Call updateViewPlanetAlliance()

        Catch ex As DBConcurrencyException
            MessageBox.Show("A concurrency erro occured. " & "the row was not deleted.", "Concurrency Exception")
            Me.ViewPlanetAlliancesTableAdapter.FillByRegionID(DsLab4.viewPlanetAlliances, CInt(Me.lstRegion.SelectedValue))

        Catch ex As ArgumentException
            MessageBox.Show(ex.Message, "Argument exception")
            Me.ViewPlanetAlliancesBindingSource.CancelEdit()
        Catch ex As DataException
                MessageBox.Show(ex.Message, ex.GetType.ToString)
                Me.ViewPlanetAlliancesBindingSource.CancelEdit()
            End Try

        Else
            Try
                Me.TableAdapterManager.UpdateAll(Me.DsLab4)
            Catch ex As DBConcurrencyException
                MessageBox.Show("A concurrency erro occured. " & "the row was not deleted.", "Concurrency Exception")
            Me.ViewPlanetAlliancesTableAdapter.FillByRegionID(DsLab4.viewPlanetAlliances, CInt(Me.lstRegion.SelectedValue))
        End Try

        End If

End Sub

这就是我的表单以及我的数据显示方式

enter image description here

0 个答案:

没有答案
相关问题