Failing to save in my database

51coder

New member
Joined
Sep 8, 2021
Messages
2
Programming Experience
Beginner
I'm developing a simple crud system where the user will be able to input data save the data and view it however they want to view the data but the application is failing to save the data into Microsoft Access and I can't figure out why because there is no error it's saving successfully but every time I reload the application I cannot see the data at all can you please help me
 
The data is almost being saved exactly as it should be, but you are looking for it in either the wrong place or at the wrong time. Here's how it works and should work, if you do things the right way:
  1. You add the MDB or ACCDB file to your project.
  2. VS prompts you to copy the file into the project.
  3. That file is now a source file in your project, just like your code files.
  4. Select the data file in the Solution Explorer.
  5. Change the Copy to Output Directory property from Copy Always to Copy if Newer. This is the critical step!
  6. When you build your project, a copy of the source data file is made and placed in the output folder with the compiled EXE.
  7. When you run your project, it is the copy in the output folder that your application connects to and modifies.
If you don't change the data file property, your working data file will be overwritten with a new copy of the source file on every build. That means that, any time you make code changes and then run your project, you will lose any changes you made previously to the data file. If you change the property as instructed, a new copy will only be created if you have made changes to the source file since you last modified the working copy. This means that you can keep using the same working copy over multiple sessions and code changes. Any time you want to start again with a clean database, you can either delete the working copy and build or temporarily change that property back to the default.

For the record, whatever method you're calling to make changes to the database is returning a number. If that number is not zero then you know for a fact that data was saved.
 
Back
Top Bottom