How do I change the path of the file as it is incorrect?

-1

System.Data.OleDb.OleDbException HResult=0x80004005 Message='F:\Stock Control Programming Project\Stock Control\bin\Debug\bin\Debug\Database\StockControlDatabase.accdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

I have an Access database located at:

F:\Stock Control Programming Project\Stock Control\bin\Debug\Database\StockControlDatabase.accdb 

However the error is saying that the path is:

F:\Stock Control Programming Project\Stock Control\bin\Debug\bin\Debug\Database\StockControlDatabase.accdb 

Which is incorrect; I would like to correct this, but I am unsure how I would do this.

screenshot of connection string

vb.net
ms-access
asked on Stack Overflow Sep 26, 2019 by ethanstreet • edited Sep 29, 2019 by ethanstreet

1 Answer

0

Your application is expecting to find the database in the folder where the .exe file resides.

You have two basic choices:

  1. move the database to the folder where the application is putting it's .exe (or .dll) file, (if you go with this option, all users of the system will have to use the .exe off a file share once it is deployed, not have a local copy - ie: distribute a link to the exe, not install the exe on each PC)

  2. Hard code the path to the database in your connection string (or data source file.) - this way when you deploy, you can put the database on a server share and install the exe file onto each PC - much cleaner...

answered on Stack Overflow Sep 27, 2019 by trevor

User contributions licensed under CC BY-SA 3.0