:( I am have been trying to update changes from my vb.net program to an access database file and it simply will not work. I have am using table adapters. I'm not familiar with SQL so i can't go that route. It updates the dataset fine but not the database...

I have pasted my code below.

Private Sub BooksBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BooksBindingNavigatorSaveItem.Click

        Me.Validate()
        Me.BooksBindingSource.EndEdit()

        Dim deletedBooks As RnrBooksDataSet.BooksDataTable = CType(RnrBooksDataSet.Books.GetChanges(Data.DataRowState.Deleted), RnrBooksDataSet.BooksDataTable)
        Dim newBooks As RnrBooksDataSet.BooksDataTable = CType(RnrBooksDataSet.Books.GetChanges(DataRowState.Added), RnrBooksDataSet.BooksDataTable)
        Dim modfiedBooks As RnrBooksDataSet.BooksDataTable = CType(RnrBooksDataSet.Books.GetChanges(DataRowState.Modified), RnrBooksDataSet.BooksDataTable)

        Try
            'Remove all deleted books from the Books table
            If Not deletedBooks Is Nothing Then
                BooksTableAdapter.Update(deletedBooks)
            End If

            'Add new orders to the orders table
            If Not newBooks Is Nothing Then
                BooksTableAdapter.Update(newBooks)
            End If

            'Update all modified orders
            If Not modfiedBooks Is Nothing Then
                BooksTableAdapter.Update(modfiedBooks)
            End If

            RnrBooksDataSet.AcceptChanges()

            ' Me.TableAdapterManager.UpdateAll(Me.RnrBooksDataSet)
            MsgBox("Update successful")

        Catch ex As Exception
            MsgBox("Update failed")

        Finally
            If Not deletedBooks Is Nothing Then
                deletedBooks.Dispose()
            End If

            If Not newBooks Is Nothing Then
                newBooks.Dispose()
            End If

            If Not modfiedBooks Is Nothing Then
                modfiedBooks.Dispose()
            End If
        End Try
    End Sub

Edited 7 Years Ago by Roax: n/a

:( I am have been trying to update changes from my vb.net program to an access database file and it simply will not work. I have am using table adapters. I'm not familiar with SQL so i can't go that route. It updates the dataset fine but not the database...

I have pasted my code below.

Private Sub BooksBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BooksBindingNavigatorSaveItem.Click

        Me.Validate()
        Me.BooksBindingSource.EndEdit()

        Dim deletedBooks As RnrBooksDataSet.BooksDataTable = CType(RnrBooksDataSet.Books.GetChanges(Data.DataRowState.Deleted), RnrBooksDataSet.BooksDataTable)
        Dim newBooks As RnrBooksDataSet.BooksDataTable = CType(RnrBooksDataSet.Books.GetChanges(DataRowState.Added), RnrBooksDataSet.BooksDataTable)
        Dim modfiedBooks As RnrBooksDataSet.BooksDataTable = CType(RnrBooksDataSet.Books.GetChanges(DataRowState.Modified), RnrBooksDataSet.BooksDataTable)

        Try
            'Remove all deleted books from the Books table
            If Not deletedBooks Is Nothing Then
                BooksTableAdapter.Update(deletedBooks)
            End If

            'Add new orders to the orders table
            If Not newBooks Is Nothing Then
                BooksTableAdapter.Update(newBooks)
            End If

            'Update all modified orders
            If Not modfiedBooks Is Nothing Then
                BooksTableAdapter.Update(modfiedBooks)
            End If

            RnrBooksDataSet.AcceptChanges()

            ' Me.TableAdapterManager.UpdateAll(Me.RnrBooksDataSet)
            MsgBox("Update successful")

        Catch ex As Exception
            MsgBox("Update failed")

        Finally
            If Not deletedBooks Is Nothing Then
                deletedBooks.Dispose()
            End If

            If Not newBooks Is Nothing Then
                newBooks.Dispose()
            End If

            If Not modfiedBooks Is Nothing Then
                modfiedBooks.Dispose()
            End If
        End Try
    End Sub

Hi Roax

Its seems like the code is commented

' Me.TableAdapterManager.UpdateAll(Me.RnrBooksDataSet)

if you still face the problem then show ur code updating basebase


Mark as solve if it helps you!!!

Edited 7 Years Ago by reach_yousuf: n/a

This article has been dead for over six months. Start a new discussion instead.