Search code examples
vb.net3-tier

3 tier architecture, could not find file


Hi i'm developing windows desktop app using 3 tier architecture with VB, when i run the application i get "Could not find file 'C:\Users\PHU-T\Documents\Visual Studio 2013\Visual_Basic_2013_SBS\Chapter 09\Orange Student\bin\Debug\Students.accdb" error. The Student.accdb file is the Data Access Layer project, the file is copied to bin\Debug folders of the Data Access Layer and Business Logic Layer projects but not in the Presentation Layer. I don't want to create fixed data source like 'C:\Users\PHU-T\Documents\Visual Studio 2013\Students.accdb' as the project will be submitted for marking. How can i solve this? i'm using the data source below.

Data Source=|DataDirectory|\Students.accdb

enter image description here


Solution

  • You need to add a reference to the DAL project from your PL project in order for the .accdb file to end up in the output directory of your main application.

    Update

    I could not reproduce this myself in Visual Studio 2013 with a similar project setup. Referencing the BLL project from the main app was all I needed to copy the DB. You might want to check the properties of the .accdb file in your project and make sure it's set to "Copy Always".