My DataGridView updates temporarily as I stop the program and start it again. But my Access Database remains updated permanently

54 views Asked by At

Would there be a chance to solve this problem? Once that I inserted a data from the Database, I wanted to update my DataGridView from the other form. Clearly the datagridview has to update as it SELECT on the table of the Database. But once that I updated the datagridview, I tried closing the system from running and restart it again. But when I checked there it didn't update. It goes like the usual datas that is from the Database. However my database is well updated and the data I inserted from the TextBoxes was there too.

Private Sub updateBtn_Click(sender As Object, e As EventArgs) Handles updateBtn.Click
    Dim newtable = New DataTable()
    provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
    datafile = "C:\Users\Anthony\Desktop\thesis\DATABASE\BookLists.accdb"
    connString = provider & datafile
    myConnection.ConnectionString = connString
    myConnection.Open()
    Dim str As String
    Try
        str = "Select * from TVL12"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        Dim da As OleDbDataAdapter = New OleDbDataAdapter()
        da.SelectCommand = cmd
        da.Fill(newtable)
        cmd.Dispose()
        myConnection.Close()
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
    TVL12.BookListTVL.DataSource = newtable

End Sub

Here's the code for Updating the DataGridView. Anyone had any ideas why does it only Temporarily updates the DataGridView?

0

There are 0 answers