13 Replies - 5615 Views - Last Post: 22 October 2015 - 01:23 PM Rate Topic: -----

#1 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Access database mysterious problems

Posted 02 February 2012 - 02:10 PM

i have text boxes binded to table from dataset. I make changes, i save changes.. then I open database with access, i can see changes...everything is ok... Then I open application again, changes are there, everything is ok. Then I close application and go to smoke.. when I come back and open application , the new data is gone. what's happening?

this is how i save changes:
       Me.Validate()
        Me.NastavniciBindingSource.EndEdit()
        Me.NastavniciTableAdapter.Update(Me.StudentDSET.Tables("Nastavnici"))
        Me.NastavniciKonzultacijeBindingSource.EndEdit()
        Me.KonzultacijeTableAdapter.Update(Me.StudentDSET.Tables("Konzultacije"))



Is This A Good Question/Topic? 0
  • +

Replies To: Access database mysterious problems

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13769
  • View blog
  • Posts: 54,956
  • Joined: 12-June 08

Re: Access database mysterious problems

Posted 02 February 2012 - 02:13 PM

Is someone over writing your changes?
Was This Post Helpful? 0
  • +
  • -

#3 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 02 February 2012 - 02:40 PM

View Postmodi123_1, on 02 February 2012 - 02:13 PM, said:

Is someone over writing your changes?

yes I was thinking that to, maybe my granny when I go to smoke. :) i don't know what's going on, now it's ok, but after some time, data is gone. Probably I doing something wrong ,i don't know what..
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13769
  • View blog
  • Posts: 54,956
  • Joined: 12-June 08

Re: Access database mysterious problems

Posted 02 February 2012 - 02:44 PM

well if you sent data to a database.. updated/inserted it... and closed out of the application that would close any connections to the database. It would be hard pressed to believe your app was some how reverting these changes after a restart. Well unless you have code in there as a test mechanism to do that.. My thought would be another user accessing the database would be at fault.
Was This Post Helpful? 0
  • +
  • -

#5 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 02 February 2012 - 03:18 PM

it's a local database on my computer., nobody can access.
when i was import database to my project there was only one record in the table. Then i add a few records, and save them. and after few minutes they disappear, only that first record remain. Then i add records again, and same thing happens even i can see the changes in access. Now it's ok ,but i still don't know where was the problem, and i know that can happen again.. and if that happen again i will come here with the full report.
what about associating files?you ask me for sp and net framework? :)
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13769
  • View blog
  • Posts: 54,956
  • Joined: 12-June 08

Re: Access database mysterious problems

Posted 02 February 2012 - 03:22 PM

So wait.. you are *NOT* closing the application down completely? That's a different story. Are you putting in database transactions? Are you not committing them? what's your insert/update/delete methods look like? Are you rolling back things?


Quote

you ask me for sp and net framework?

What?
Was This Post Helpful? 0
  • +
  • -

#7 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 02 February 2012 - 03:32 PM

yes i close application..then open access to see the changes..close access,then open application again, i can see the changes, then close application and open again, then i can see new records and sometimes i don't.

you ask me for sp and net framework?
asocciating files
Was This Post Helpful? 0
  • +
  • -

#8 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 02 February 2012 - 04:22 PM

HERE WE GO AGAIN!!. Till now everything was fine.30min ago I was testing application, reopen application 10-20 times and every time insert new data. I left application for about 30min and open again. The new records are gone! There are only few records left.
Was This Post Helpful? 0
  • +
  • -

#9 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 03 February 2012 - 02:37 AM

View Postmodi123_1, on 02 February 2012 - 03:22 PM, said:

Are you putting in database transactions? Are you not committing them? what's your insert/update/delete methods look like? Are you rolling back things?


I have made a new project with just a few lines of code. The same thing, but with the same problem.
here you can download the project.
download
This is complete code:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'StudentDataSet.Nastavnici' table. You can move, or remove it, as needed.
        Me.NastavniciTableAdapter.Fill(Me.StudentDataSet.Nastavnici)

    End Sub

 
    Private Sub btnSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSAVE.Click
        Me.Validate()
        Me.NastavniciBindingSource.EndEdit()
        Me.NastavniciTableAdapter.Update(Me.StudentDataSet.Tables("Nastavnici"))

    End Sub

End Class


Was This Post Helpful? 0
  • +
  • -

#10 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1727
  • View blog
  • Posts: 5,704
  • Joined: 25-September 09

Re: Access database mysterious problems

Posted 03 February 2012 - 09:59 AM

OK, here's your problem, I you look at your project folder you will see a database (student.mdb)

Now if you go into the bin/debug folder you will again see a database (student.mdb) along with your .exe of the compiled version.

When you make a change to your code and re-run your program a new build of the exe is made and a new copy of the database is put in the bin\debug folder, it is a snapshot of the one you have in your project folder.

One way to alleviate this issue is to open your project and in the solution explorer click on your database. Then in the properties, set the Copy to Output Directory to Copy if newer instead of always copy.

I'm not fluent with using the objects in the IDE but I did see in a video from Beth Massi about making sure to set this option to keep from overwriting your data.

Here's a link to a page where she talks about it.

You might be interested in her Forms Over Data videos. The link is in the article.

This post has been edited by CharlieMay: 03 February 2012 - 10:11 AM

Was This Post Helpful? 1
  • +
  • -

#11 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 03 February 2012 - 10:24 AM

Thank you. I will set Copy to Output Directory to Copy if newer and I will inform you of the results.
Was This Post Helpful? 0
  • +
  • -

#12 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1727
  • View blog
  • Posts: 5,704
  • Joined: 25-September 09

Re: Access database mysterious problems

Posted 03 February 2012 - 10:32 AM

I already know the results but I really recommend you reading the link I provided and watching those videos, it will save you a lot of headaches in the long run. There is a wealth of information there.

Edit:
And make sure you read and understand the last paragraph on the page:

Quote

Just remember to mark your databases as Copy if Newer that way you only "lose" data when you make changes to the structure of the database itself or if you add data via the Visual Studio designers. For more information check out this post as well. I'll be creating a video on how to work with local database files including how to deploy them to your users in the next series.


Because after you get this working, and decide to make a change to your database schema you WILL once again lose the data in your working database file because the project database (Which has not been updated with data) WILL be newer due to the schema changes and will copy over the working database, once again making you believe that your data is "mysteriously" disappearing.

This post has been edited by CharlieMay: 03 February 2012 - 10:41 AM

Was This Post Helpful? 2
  • +
  • -

#13 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 139
  • View blog
  • Posts: 841
  • Joined: 21-December 11

Re: Access database mysterious problems

Posted 03 February 2012 - 11:47 AM

ok, you make me believe. Everything is working. That's a big relief for me now when i know what's the problem. I can go sleep now. Thank you very much!
Was This Post Helpful? 0
  • +
  • -

#14 xunty  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 22-October 15

Re: Access database mysterious problems

Posted 22 October 2015 - 01:23 PM

View PostCharlieMay, on 03 February 2012 - 09:59 AM, said:

OK, here's your problem, I you look at your project folder you will see a database (student.mdb)

Now if you go into the bin/debug folder you will again see a database (student.mdb) along with your .exe of the compiled version.

When you make a change to your code and re-run your program a new build of the exe is made and a new copy of the database is put in the bin\debug folder, it is a snapshot of the one you have in your project folder.

One way to alleviate this issue is to open your project and in the solution explorer click on your database. Then in the properties, set the Copy to Output Directory to Copy if newer instead of always copy.

I'm not fluent with using the objects in the IDE but I did see in a video from Beth Massi about making sure to set this option to keep from overwriting your data.

Here's a link to a page where she talks about it.

You might be interested in her Forms Over Data videos. The link is in the article.




Thank you very much,... after searching about 30 mins, i finally found a solution, i am working for my college miniproject,.. here is a snapshot :D Posted Image

Posted Image
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1