Datagridview编辑不更新数据库

时间:2017-10-31 12:18:13

标签: vb.net datagridview

我有一个绑定到“ParsreelsBindingsource”的datagridview。当我编辑DGV时,canges显示没有错误,但没有更新数据库。我使用以下代码保存:

var SessionStorage = {
    station_name: 'TEST',
    set_name_station: sessionStorage.setItem('name_station', this.station_name),
    get_name_station: sessionStorage.getItem('name_station'),

    launch_functions_sessionStorage: function () {
        this.onReservation();
    },

    onReservation: function () {
        console.log(this.get_name_station)
    }
};

此致

编辑:数据集代码:(我希望这就是你想要的)

   Private Sub UPDATE_Click(sender As Object, e As EventArgs) Handles UPDATE.Click, UPDATE.Click

    Me.Validate()
    Me.ParsreelsBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.SkeduleringDatabasisDataSet)
    Me.Close()

End Sub

1 个答案:

答案 0 :(得分:1)

任何时候我必须处理datagridviews,以下工作正常

Friend Class MyClass

    Private daFoo as dsMyDataSetTableAdapters.TableFooAdapter = new dsMyDataSetTableAdapters.TableFooAdapter()
    Private dtTable as Datatable

    Private Sub setUpTheDGV()
        dtTable = daFoo.GetMyData()
        myDGV.DataSource = dtTable
        Refresh()
    End Sub

    'Do things, call methods, change the datagridview's contents....

    Private Sub updateMyData()
        daFoo.Update(dtTable)
    End Sub

End Class

对datagridview所做的更改将应用​​于数据表,并且适配器会对.update调用执行所有繁重操作。希望它有所帮助。