I am building an application in Visual Studio 2010 using .Net 4.0 and an Access Database.
I’ve specified the existing path of my database i.e. D:/project/record.accdb. After building the application, when I install it on my own computer and run it, it gives me a database path error.
My application is working fine on clicking F5 (Debugging), except that it shows the error
“Path not found.”
I’ve build my project using the following steps:
- Build
- Build “project Name”
- Use CD/DVD for installation
- Finish
How can I fix this issue?
As it sounds, on your Dev PC it runs fine, but not on a different machine where you want to deploy it to.
Check if you have Microsoft Access installed on the other PC (the one without Dev tools).
Repeat your tests after you have installed Access.
Update:
You have written me recently that the path does not work. Try the following to create a valid datasource string:
.UDL, e.g.Access.UDLC:\Documents and Settings\All Users\My Documents\Database1.accdbIf you open the UDL file (in our example Access.UDL) using NOTEPAD afterwards, you see the correct datasource string:
You can use this string either directly in the C# code or you store it in your app.config file and load it. If the path should be dynamic you can do the following (the following example uses a hard-coded datasource string):
This will insert the path stored in the variable
strPathinto the datasource stringstrDS. As mentioned before, you could also load this string from the app.config.