Question After Compiled, App can not find Access table

mrRogers

Well-known member
Joined
Jan 23, 2016
Messages
45
Programming Experience
3-5
App works fine and has several tables from one Access Data Base. After compiled i try to open and get an error that it can not locate the Access Data Table ( in a strange address that I did not specify). On creation i saved the DB in the output file. Any reading material on how to get this set up correctly?
 
In order for you to determine that the app works fine it would already have to be compiled. Do you actually mean after installing elsewhere? How EXACTLY is the app being deployed? Most likely you are not doing that properly. Here's what you should have done and be doing:

1. Add your Access data file to your project.
2. When prompted, copy the file to the project folder. You can now ignore the original file as the one in the project folder becomes your source file.
3. Make sure that the Copy To Output Directory property for the data file is set to Copy If Newer. This means that any time you make a change to the source file, a new copy will be created in the output folder. It's that copy in the output folder that you use at run time, whether while testing or releasing.
4. If you're using ClickOnce deployment, make sure that the Build Action is set to Data (or something close to that, can't recall the exact name). That ensures that the file is treated as a data file and is installed to the data directory.
5. Make sure that you use "|DataDirectory|" for the folder path in your connection string so that it will just work without change between testing and release.

Most likely the strange path that you mention is the ClickOnce data directory, where it is expecting to find your data file that is not there.
 
Ref above: I am using click once and thanks for clarifying for me the difference between deploying and compiling. I did not realize it compiled each time you build and run it.

No. 1 &2 - I believe I did correctly as I selected "yes" when asked if I wanted to include with project
No. 3-in solution explorer I selected my accdb and in the "copy to output dir" selected "Copy if Newer". so this looks right as well. Note I did set the dataset to the same if that makes a difference.
No.4- I found Compile, Build Output Path-set to "bin\DeBug" seems correct?
No.5- not sure I understand but the full path of the accdb shows to be a path in a sub folder two below where my original application resides C:\Applications\MaintSkills3.25.16\MaintSkills3.25.16\MaintSkills3.25.16.accdb

Should I change the path in no.4 ?
 
found Connection string:

[connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\MaintSkills3.28.16.accdb"]
 
The ACCDB file should be in the same folder as all your other source files, i.e. VB code files and the like, because it is a source file. When you build, which is done each time you debug and when you publish, the code files are compiled and the output, i.e. the EXE is written to the output folder and any other files that are required are copied there too, e.g. the config file and the ACCDB data file.

When you publish, the contents of the output folder is packaged into an installer. It should be a Release build, rather than a Debug build, that is deployed. I don't use ClickOnce so I'm not sure whether that happens automatically or you have to change the build configuration. I think it's automatic.

Have you looked that Publish properties to see whether the data file is being included?
 
In Click Once -Publish, under Application Files, it lists .accdb, .exe, .exe.config, .exe.manifest. Does this address where the data files are included?

Back to the properties of the .accdb; the Build Action is set to "Content"
The corresponding dataset Build Action is set to "Nothing"

Does any of this shed any more light on my issue? I do not have a clue how it is picking up such a strange address that the .accdb should be in.
 
In Click Once -Publish, under Application Files, it lists .accdb, .exe, .exe.config, .exe.manifest. Does this address where the data files are included?
What is the Publish Status for the ACCDB file in the Application Files dialogue? It should be Data File or the like or else it won't be installed in the data directory.
I do not have a clue how it is picking up such a strange address that the .accdb should be in.
That is the ClickOnce data directory. That is the path that the "|DataDirectory|" place-holder in your connection string resolves to for a ClickOnce-deployed application.
 
I apologize for not seeing what you were saying about the publish status earlier. I finally found it and changed it to "Data File". Your recommendation fixed my problem.
Thanks So Much!
resolved
 
Back
Top