在网格单元格值更新上更新数据库表

时间:2019-02-11 09:41:03

标签: mysql vb.net devexpress

在我的表单上,我只有2个控件,一个组合框用于保存数据库中每个表的名称,而另一个gridcontrol则用于在组合框中选择表时显示数据。

一旦更改了网格控制单元的值,如何更新数据库表?

这是我的代码,它填充了gridcontrol:

 Private Sub comboBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles comboBox.SelectionChanged
    gridControl.ItemsSource = returnTable("select * from " & comboBox.SelectedItem("TABLE_NAME"))
End Sub

 Public Function returnTable(ByVal queryString As String)
    Dim query1 As String = queryString
    Dim table As New DataTable
    Using connection As New MySqlConnection(konekcija)
        Using adapter As New MySqlDataAdapter(query1, connection)
            Dim cmb As New MySqlCommandBuilder(adapter)
            table.Clear()
            adapter.Fill(table)
            Return table
        End Using
    End Using
End Function

1 个答案:

答案 0 :(得分:0)