Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have developed and distributed software in VB.net and MS-Access database,
Now I have made changes in database so I want to create an utility which will replace
the existing database file with new created, so that I can distribute that Update utility to client. What is easiest way to do it? please share your ideas.
Posted

1 solution

If you want the customer to lose all their data in the database, all you have to do is copy the new blank database file over the old one.

If you want to retain the data, you have to options, neither is very nice in Access. You can write a migration utility to move the old database, copy the new, blank, database file in place, then copy the records over for each table, one by one.

The other option is to make a backup copy of the old database, then run the SQL statements to modify the tables in the existing database. You, of course, have to write each SQL statement to do the modifications yourself.
 
Share this answer
 
v2
Comments
123sj 29-Aug-12 1:25am    
Thanks for your answer, I think first option is I am going to use, but I am not getting how to copy the new database file over the old one, means I want to create a simple project and want to distribute to clients, when user will run this simple project, GUI will show progress bar and at back end the old database file will be replaced by new one contained in simple project setup.
I hope you are getting my query. Please give some sample code or any way to move ahead.
Dave Kreskowiak 29-Aug-12 8:02am    
I screwd up my post a bit. The first option is only if you want the customer to lose all their data in the old database. If that's the case, you won't need a progress bar as copying an empty database file over the old one will only take a second. And it's just a simple File.Copy operation. See http://msdn.microsoft.com/en-us/library/9706cfs5.aspx.
123sj 29-Aug-12 8:17am    
Ya thanks, I got it, and it seems useful but the problem is my destination path is not fix, that is, clients may have installed software at any location, so how do program knows destination path? is there any way to search each path by file name??
Dave Kreskowiak 29-Aug-12 8:24am    
You create an installer for your application, which will install to Program Files\Somefolder by default. You could even write that path to the registry at install time.

Oh, if you're putting your database file under Program Files, you're making a huge mistake. Normal users don't have write permissions to anything under Program Files in Windows Vista, Windows 7, and Windows 8. Writeable files are better placed under and appropriate file location depending on if all users on the machine use the same database file (CommonApplicationData) or each user on the machine has their own copy of the database file (ApplicationData or LocalApplicationData). See http://msdn.microsoft.com/en-us/library/14tx8hby.aspx for more information on this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900