以Windows格式vb.net刷新DataGridView

时间:2016-02-16 16:37:29

标签: vb.net datagridview

我有两个表单,分别是表单A和表单B.当我单击表单B上的保存按钮时,我希望表单A的 DataGridView 刷新。

我怎么能这样做? 我真的需要帮助,有人可以帮助我吗?

我插入此代码的数据:

 provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\311026\Desktop\PAP2\Biblio.accdb"
    connString = provider
    myConnection.ConnectionString = connString
    myConnection.Open()
    Dim str As String
    str = "Insert into Livrosescola([NomeLivro], [AutorLivro], [EditoraLivro], [AnoLivro]) Values (?,?,?,?)"
    Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)

    cmd.Parameters.Add(New OleDbParameter("NomeLivro", CType(NomeLivroTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("AutorLivro", CType(AutorLivroTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("EditoraLivro", CType(EditoraLivroTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("AnoLivro", CType(AnoLivroTextBox.Text, String)))


    Try
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        myConnection.Close()
        NomeLivroTextBox.Clear()
        AutorLivroTextBox.Clear()
        EditoraLivroTextBox.Clear()
        AnoLivroTextBox.Clear()


    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

谢谢!!

0 个答案:

没有答案