Very simple VB6 project. Follow the steps as they are written and it can be done quickly. Questions? ask me. This code will be used in another program where a user will be prompted to restore an old file. Your code must be CLEAN AND WELL COMMENTED as it will be used by other programmers.
To be done in CODE ONLY (no .OCXs). Yes, you can use API calls. For DB stuff, use MS DAO 3.6.
Place one button on a form. If you click on it, it brings up a windows "open" dialog box.
Looking for files of type ".dat". Basically, the user is prompted to select a restore file of type .dat.
if the user cancels, nothing happens.
if the user selects a file, one of the following happens:
{{CONTINUED IN DELIVERABLES SECTION BELOW}}
## Deliverables
{{ continued from above }}
1. if the user selects [login to view URL]\[login to view URL], then it gives a messagebox "Error 1"
2. if the user selects a different .dat file, then this is what happens:
a) the file selected from the open dialog box is copied to {[login to view URL]} and renamed to mylogbook_restored.dat. If a file {[login to view URL]}\[login to view URL] already exists, it is deleted before this new file is copied. if there is an error in copying, an intelligent error message is made and the process ends.
b) set the file's permissions to r/w (maybe this needs an API call?). This is important because sometimes the file will have been stored on a CD-ROM.
c) the file, even though it is called .dat, is an ms-access file. the database is opened (MS DAO 3.6). when you open it, use password "testpassword" as the real one will have a password.
if the file can not be opened, MSGBOX an error and exit.
d) check for the existence of two tables "LOG" and "AIRCRAFT". if these two tables are not found, then msgbox an error and exit.
e) test the RW permissions by making a temporary table ("RWTEST_TABLE") in the DB. write to it and then read back what you wrote. if there is an error, msgbox an error and exit.
--- at this point, if everything is ok, we assume that the file is fine. so, we continue the restore:
f) {[login to view URL]}\[login to view URL] is renamed to [login to view URL] where MM_DD_YYYY is the month, day, year and SEQ is a sequence number (1..2..3.. if already a restore backup exists for that day).
g) if an error is encountered in renaming in step f) ignore the error and continues to step h)
h) rename [login to view URL] to [login to view URL]
i) verify that the file has been properly renamed. msgbox success.
**DELIVERABLES**
clean and working code as described above. VB6 / DAO3.6. API calls ok. NO OCXs.
## Platform
VB6