I’ve made a program to manage a movie collection and it stores the data in an access database. I realise it can be done manually, but I’d like it to be possible to export and import the databases from within the program, so that users don’t have to start their database from scratch every time I bring out a new version.
How do I go about doing that?
I’m still pretty new to programming so if I’ve forgotten to mention anything, please do ask!
You need to export each table’s records to a file in a format of your choosing (ie, csv, xml, your own format, etc) with a export version number (so later versions of your program know what format they will be reading in). This is serializing your data, and you can find lots of information on how to save out data.
To import, you will need to read in each exported file, and insert this into a new database. This is just the other face of serializing your data, so again, there are lots of informaiton sources on how to do this.
If you are going to allow users to re-import data into an existing database, you will need to decide on how you handle duplicate entries, and whether there is a batch process that users can use so they only have to pick how to handle duplicates once (ie, have user choose once to overwrite all existing records or have user choose to skip all existing records).