Avatar of Iver Erling Arva
Iver Erling Arva
Flag for Norway asked on

Data entered in Access table via VB seem to work, but missing next time file is opened.

I have used MS Access 2013 to create a db-file with some data. I have then written some code in VB.NET that opens and access the data. I can create new records, and I can page through them back and forth and all seems fine. But when I run my program again, the data I entered has gone missing. I use
    Private Function storeData(ByVal mySql As String) As Boolean
        Dim ret As Boolean = False
        Dim ac As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & myPath)
        Try
            Using ac
                Dim myCommand = New System.Data.OleDb.OleDbCommand(mySql, ac)
                myCommand.Connection.Open()
                myCommand.ExecuteNonQuery()
                myCommand.Connection.Close()
            End Using

            ret = True
        Catch ex As Exception
            MsgBox("There is something wrong." & _
                   vbNewLine & ex.ToString, MsgBoxStyle.Exclamation, "SQL Error")
        End Try
        Return ret
    End Function

Open in new window

The SQL command looks something like this:
Insert into NAD(Name,Address,Postnumber,Telefonnumber,Epostaddress,Webpage) values('Thor','Oslo','0575','999 88 777','epost@epost.no','www.web.com');

Open in new window

and seem to work fine, and when I browse through the table using my program after having entered a new record, I can see the new records. But when I close the program and reopens it, or query the DB from outside, the newly entered data have disappeared. What am I missing? Do I need som kind of file save or commit or something?
Microsoft AccessVisual Basic.NET

Avatar of undefined
Last Comment
Iver Erling Arva

8/22/2022 - Mon
Fernando Soto

Check the location of where the Access DB file is. Then go to the programs project folder debug\bin directory and see if there is a copy there, if so open that version of the DB file and see if the records are there.
ASKER CERTIFIED SOLUTION
Jacques Bourgeois (James Burger)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Iver Erling Arva

ASKER
Thanks for your advice! I will check this as soon as I get a chance, hopefully within a day or two! So easy to miss such things ;-)

IVer
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck