0

This is my first post on stackoverflow so please hang with me. I am attempting to update an access database using VB.NET. Using the following series of videos (starting with this one), we have been able to properly use our form to save new data into the access database. https://www.youtube.com/results?search_query=vb.net+ms+access+database+tutorial+1+%23+add+new+remove+save+data+in+database+using+vb.net

However, when we start up the form again after opening up access to make sure the updates have occurred (which they always do), none of our changes are there. And when we open up access again the changes we made that showed up in the access database are gone, and the access database goes back to its original state (the state it was when we linked it to visual studio in the first place).

Below is the code we have so far, we appreciate any help you can give us!

Thanks.

Imports System
Imports System.Data
Imports System.Data.SqlClient

Public Class Form1

    Private Sub Sheet1BindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles Sheet1BindingNavigatorSaveItem.Click
        Me.Validate()
        Me.Sheet1BindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(MIS275_Small_BusinessDataSet)
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MIS275_Small_BusinessDataSet.Sheet1' table. You can move, or remove it, as needed.
        Timer1.Start()
        Me.Sheet1TableAdapter.Fill(MIS275_Small_BusinessDataSet.Sheet1)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Sheet1BindingSource.AddNew()
    End Sub

    Private Sub Save_Click(sender As Object, e As EventArgs) Handles Save.Click
        Try
            Sheet1BindingSource.EndEdit()
            Sheet1TableAdapter.Update(MIS275_Small_BusinessDataSet.Sheet1)
            MessageBox.Show("Data Saved")
        Catch ex As Exception
            MessageBox.Show("Error")
        End Try
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim count As Integer
        count = Sheet1BindingSource.Count
    End Sub

End Class
das-g
  • 9,718
  • 4
  • 38
  • 80
  • 3
    It sounds like you have the project set to `Copy Always` the blank/empty DB for use. Place it in an AppData folder and connect to it there, or change the "copy to..." DB property in the project. – Ňɏssa Pøngjǣrdenlarp May 05 '15 at 19:44
  • Not exactly a duplicate, but the concept is the same http://stackoverflow.com/questions/17147249/why-saving-changes-to-a-database-fails/17147460#17147460 – Steve May 05 '15 at 20:50

0 Answers0