title: How to refresh datagrid in vb.net after update
body: <p>This is a part of module(Update book's Details) in Library Management System. But when I change the details and click the update button, the updated data successfully stored in Database, but the updated data isn't refresh in the datagrid simultaneously.</p>
  
  <pre><code>Imports System.Data
  Imports System.Data.OleDb
  Imports System.Data.Odbc
  Imports System.Data.DataTable
  
  Public Class frmBooksUpdate
  
      Dim myConnection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\LMS_DB.accdb")
      Dim con As OleDbConnection
      Dim provider As String
      Dim dataFile As String
      Dim connString As String
      Dim ds As DataSet = New DataSet
      Dim da As OleDbDataAdapter
      Dim tables As DataTableCollection = ds.Tables
      Dim source1 As New BindingSource()
  
      Private Sub Refreshdata()
          da = New OleDbDataAdapter("SELECT [BookID], [Title], [Author], [Publisher], [Category], [Price], [ISBN] FROM tblBooks", myConnection)
          da.Fill(ds, "tblBooks")
          Dim view1 As New DataView(tables(0))
          source1.DataSource = view1
          DataGridView1.DataSource = view1
          DataGridView1.Refresh()
  
      End Sub
      Private Sub frmBookSearch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          Refreshdata()
      End Sub
  
      Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
          Dim i As Integer
          i = DataGridView1.CurrentRow.Index
  
          txtBookID.Text = ds.Tables(0).Rows(i).Item(0)
          txtTitle.Text = ds.Tables(0).Rows(i).Item(1)
          txtAuthor.Text = ds.Tables(0).Rows(i).Item(2)
          txtPublisher.Text = ds.Tables(0).Rows(i).Item(3)
          txtCategory.Text = ds.Tables(0).Rows(i).Item(4)
          txtPrice.Text = ds.Tables(0).Rows(i).Item(5)
          txtISBN.Text = ds.Tables(0).Rows(i).Item(6)
  
      End Sub
  
  
      Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
  
          myConnection.Open()
          Dim str As String
          str = "UPDATE [tblBooks] SET [Title] = '" &amp; txtTitle.Text &amp; "' , [Author] = '" &amp; txtAuthor.Text &amp; "', [Publisher] = '" &amp; txtPublisher.Text &amp; "', [Category] = '" &amp; txtCategory.Text &amp; "', [Price] = '" &amp; txtPrice.Text &amp; "', [ISBN] = '" &amp; txtISBN.Text &amp; "' WHERE [BookID] = " &amp; txtBookID.Text &amp; ""
  
          Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
          Try
              cmd.ExecuteNonQuery()
              cmd.Dispose()
              myConnection.Close()
  
              MessageBox.Show("The Book Updated", "Book Updated", MessageBoxButtons.OK, MessageBoxIcon.Information)
  
  
              txtAuthor.Clear()
              txtBookID.Clear()
              txtCategory.Clear()
              txtISBN.Clear()
              txtPrice.Clear()
              txtPublisher.Clear()
              txtTitle.Clear()
  
          Catch ex As Exception
              MsgBox(ex.Message)
          End Try
  
      End Sub
  
      Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
          Me.Close()
      End Sub
  End Class
  </code></pre>