Link to home
Start Free TrialLog in
Avatar of author3000
author3000

asked on

Locating updated external database. Visual Basic

(Apologies in advance if this has been answered previously; I just couldn't find it, if it was.)

I have a VB 2013 Express for Desktop app that reads and writes to an Access 2010 database. That is all working just fine. In fact I can publish it and it works fine. (I guess.) And it took me FOREVER to find a way to get the file to come along with the published app. (I finally "added" the file to my Solution; set the Build action to Content; and the Copy to Output Directory to Copy Always). Well, the published program runs fine and I can make changes to the database as shown by fields on my form that display the updated data.

Wow, was I excited. Except....I'd like to find where that updated file is on my hard drive. Because if my client updates that database I want to get a copy of that database to replace MY (now out-of-date) copy.

No clue as to how to find that updated file (if it exists). Maybe I'm doing something else wrong, too. But I need SPECIFIC instructions on how to do it (i.e., not a lot of tech-talk; I don't do this very often so, while competent I'm not an polished expert).I DID find the file with this appendage: .deploy.
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of author3000
author3000

ASKER

Well, well, well. what a deal. The path to the file is this:

C:\Users\TheDad\AppData\Local\Apps\2.0\X3EWETCO.58H\XA1RMCMM.BY1\glyp..tion_0021903f6689be8c_0001.0000_5f5ab15fe4d3cd64\Glyphs.accdb

MY GOOD LORD!

I'm going to award you the points. BUT would you be so kind as to tell me how to get that stinking file to store somewhere else into a folder that is reasonable? Like C:\StoredGlyphs.
The word publish is used for anything nowadays (even paper books :-)) so I did not make the connection right there. You deployed your application with ClickOnce, didn't you?

Well, that strange path is is what ClickOnce does. For all its versatility, you have to pay a little bit. One of these "payments" is that you have no control over the path where stuff is deployed. Because it handles things by itself, ClickOnce has its own way of keeping track of the different versions of the application, and this way involves these strange directories.

Which brings another problem that you have not encountered yet. ClickOnce creates a new directory, with a new name,  with each update, and installs the new version there. This enables that wonderful feature that permits a user to rollback an installation if an update happens to do bad things. But this means that installing the database in the same directory as the application is not a good idea with ClickOnce, specially if you want to act on it from outside as is your case.

What I did when I deployed Access databases with ClickOnce was to start my applications with the following algorithm:

- Check if the database file exists in a specific directory of my choosing.
- If if does not, copy the database file that was distributed with the application in that directory.
- If it does exist, then do nothing, the database is already "installed".
- Set my ConnectionString to that location.

This installed the database only on the first run of the application, in a specific place that I could easily access and that did not change name everytime I deployed an update.
Wow! What a great idea for locating the database! I just want the user to be able to easily find the DB so we can exchange updates and just update the DB without fiddling with the entire application. Thank you a lot. I wish I'd posted this before I had wasted tons of time Google-ing to find the solutions you provided.