0

我需要将DataTableMicrosoft Access 中的 a 加载到DataSetusing 中OleDb。我需要将其加载DataSetDataGridView. 然后,我需要对Microsoft AccessDataGridView中的原始文件进行更改并更新这些更改。DataTable

到目前为止,这是我的代码:

Public tblName As String = "Criteria"

Dim ds As New DataSet()
Dim da As OleDbDataAdapter
Dim cmdBuilder As OleDbCommandBuilder
Dim Bsource As New BindingSource

Public Sub Show_Panel_Manage_Calculations()
    Panel_Manage_Calculations.Show()

    Nordeen_Investing_3.con.Open()
    da = New OleDbDataAdapter("SELECT Calculation, [Interval], Formula FROM " & tblName & "", Nordeen_Investing_3.con)
    cmdBuilder = New OleDbCommandBuilder(da)
    da.Fill(ds, "Criteria")

    Bsource.DataSource = ds
    DataGridView_Manage_Calculations.DataSource = Bsource
    Nordeen_Investing_3.con.Close()

End Sub

Private Sub Button_Update_Click(sender As Object, e As EventArgs) Handles Button_Update.Click
    Nordeen_Investing_3.con.Open()
    da.Update(ds, "Criteria")
    Nordeen_Investing_3.con.Close()
End Sub

现在我的数据DataTable没有显示在我的DataGridView.

4

1 回答 1

1

DataSource期望的是一个,Table而不是整个DataSet。你也不需要这个BindingSource部分。示例代码:

DataGridView_Manage_Calculations.DataSource = ds.Tables(0) 'By assuming that you want the first table
于 2013-10-14T20:52:53.287 回答