将DataGrid从主窗体更新为另一种窗体

时间:2015-11-16 11:11:51

标签: vb.net datagridview

我有2个表格。在主窗体中有DataGridView和2个按钮(添加按钮和更新按钮)。当用户单击更新按钮时,我想将DataGridView从主窗体更新为另一种窗体。更新按钮和第二种形式的代码是什么?

我有主表单的代码

Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    MySISConn = New OleDbConnection

    provider = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = "

    dataFile = "C:\Users\admin\Documents\Visual Studio 2010\Projects\SIS\SIS\SIS.accdb"
    connString = provider & dataFile
    MySISConn.ConnectionString = connString

    Dim SDA As New OleDbDataAdapter
    Dim dbDataSet As New DataTable
    Dim bSource As New BindingSource
    Try
        MySISConn.Open()
        Dim Query As String
        Query = "Select * from StudentInformation "
        SISCommand = New OleDbCommand(Query, MySISConn)
        SDA.SelectCommand = SISCommand
        SDA.Fill(dbDataSet)
        bSource.DataSource = dbDataSet
        DataGridView1.DataSource = bSource
        SDA.Update(dbDataSet)
        MySISConn.Close()
    Catch ex As OleDbException
        MessageBox.Show(ex.Message)
    Finally
        MySISConn.Dispose()
    End Try
End Sub

0 个答案:

没有答案