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.
Your application is expecting to find the database in the folder where the .exe file resides.
You have two basic choices:
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)
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...
User contributions licensed under CC BY-SA 3.0