Results 1 to 4 of 4

Thread: pls help. problem with mdf file location.

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2009
    Posts
    106

    pls help. problem with mdf file location.

    hi all, my vb program r connected to mdf file to allow update,view n delete of database data. the mdf file is located at the \bin folder.

    the problem is whenever i run the program, it will automatic copy the mdf file from the \bin folder to \bin\Debug\bin folder.

    all the update n delete is then done on the mdf file located at \bin\Debug\bin.
    when i run the program again, it will copy the mdf file from \bin and overwrite the mdf file at \bin\Debug\bin.

    i try to delete the mdf file at \bin folder but error saying "unable to copy mdf from \bin to \bin\Debug\bin".

    anyone know any solution? thanks

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

    Re: pls help. problem with mdf file location.

    The file should not be in the bin folder. It should be in the project folder, above the bin folder, along with all the other source files. When you build your project a copy is made and placed in the bin\Debug or bin\Release folder, along with the other output, and it's that copy that your app uses. Follow the first link in my signature for more information about how to configure that behaviour.
    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
    Lively Member
    Join Date
    Feb 2009
    Posts
    106

    Re: pls help. problem with mdf file location.

    Quote Originally Posted by jmcilhinney View Post
    The file should not be in the bin folder. It should be in the project folder, above the bin folder, along with all the other source files. When you build your project a copy is made and placed in the bin\Debug or bin\Release folder, along with the other output, and it's that copy that your app uses. Follow the first link in my signature for more information about how to configure that behaviour.
    hi, to place the mdf file in the bin folder is a requirement from my lecturer. however, i found out another solution. go to the properties for the mdf file. under Copy to Output Directory, select Copy if Newer. this help, but anyway, thanks for ur solution too.

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

    Re: pls help. problem with mdf file location.

    If placing the database in the bin folder is a requirement then you should probably be setting Copy to Output Directory to Copy Never and then specifying the absolute path of that file in your connection string.

    If putting the database in the bin folder is really what your lecturer wants and not your misinterpretation of their instructions then I think that that's a very bad idea, and you can quote me on that. It offers no advantage over placing the database in the project folder during development and it creates a handicap when deploying, because your absolute path will no longer be valid. If you do it the way it's intended to be done then it will just work, during development and once deployed, with no changes.
    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

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