Results 1 to 3 of 3

Thread: How to include mdb file inside vb.net Application

  1. #1

    Thread Starter
    Banned
    Join Date
    Apr 2020
    Location
    https://t.me/pump_upp
    Posts
    61

    How to include mdb file inside vb.net Application

    Dear All

    I have a vb.net application connected to access database which is inside the Application Under the debug Folder , when I add this database as existing item it copies it to another path ?

    then I have 2 copies of the database one inside the debug folder which updates data and runs OK and another copy outside the debug folder which does not update data

    what should I do to have one database which updates data not two.

    Also, when I remove the outside database the application does not find the database ?

    What is the solution to this ?

    I tried Content and Do not copy , copy always , copy if newer

    Nothing works

    Thanks in Advance, Regards

    Moheb Labib
    Last edited by meho2020; Jan 4th, 2022 at 04:17 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to include mdb file inside vb.net Application

    It's working properly and you're trying to break it. The data file should not be in the bin folder to start with. It should be created in your project folder or somewhere completely outside the project. You then add the data file as an existing item to your project. If the file is outside the project folder, you will be prompted to copy it to the project folder, which you should do. You now have your data file in your project, with the other source files.

    When you build your project, that source file is copied and saved to the output folder. It is that copy that your application should connect to when you are testing/debugging. You can make as big a mess of that copy as you want to, safe in the knowledge that your original source file is still in its pristine state. By default, the Copy to Output Directory property will be set to Copy Always. That means that any time your project is built, a new copy is created in the output folder and you will lose any changes you made the last time you debugged. That's generally not what you want. If you change it to Copy if Newer then a new copy will only be created if you make changes to the original source file, e.g. change the schema or add new initial data.

    Because your source file remains clean, when it comes time to deploy your app, you create a Release build and you'll get a fresh copy of the data file in that output, so there's no need to clean all your test garbage out to release.

    You might like to follow the first link in my signature for a bit of official information on the subject from Microsoft.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Banned
    Join Date
    Apr 2020
    Location
    https://t.me/pump_upp
    Posts
    61

    Re: How to include mdb file inside vb.net Application

    Dear jmcilhinney

    Thanks your reply, Regards

    Moheb Labib

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width