In a VB6 program, I put this in a module to open a database on the startup form:
dbname = GetSetting("myCompany", "DataBaseName", "FileName", ".")
Set db = DBEngine.Workspaces(0).OpenDatabase(dbname, , True)
Say, the database named is myDB.mdb. When the program is running, some timer controls are running all the time in the background. Then on an option page, users can change the database file, say, from myDB.mdb to myDB1.mdb. So I use:
newDB = myDB1.mdb
SaveSetting "myCompany", "DataBaseName", "FileName", newDB
Set db = DBEngine.Workspaces(0).OpenDatabase(newDB, , True)
Now the problem is any pages already loaded (including the start up page) are still pointing to the old database. Moreover, both myDB.mdb and myDB1.mdb files are staying open in the hard drive, that is, 2 corresponding ldb files exist.
1. How can I close the old database file and make its ldb file disappear? I tried using db.close before setting db to newDB but came up with errors from some background timers.
2. How can I refresh my whole program so that it points to the new database file?
Jeff
dbname = GetSetting("myCompany", "DataBaseName", "FileName", ".")
Set db = DBEngine.Workspaces(0).OpenDatabase(dbname, , True)
Say, the database named is myDB.mdb. When the program is running, some timer controls are running all the time in the background. Then on an option page, users can change the database file, say, from myDB.mdb to myDB1.mdb. So I use:
newDB = myDB1.mdb
SaveSetting "myCompany", "DataBaseName", "FileName", newDB
Set db = DBEngine.Workspaces(0).OpenDatabase(newDB, , True)
Now the problem is any pages already loaded (including the start up page) are still pointing to the old database. Moreover, both myDB.mdb and myDB1.mdb files are staying open in the hard drive, that is, 2 corresponding ldb files exist.
1. How can I close the old database file and make its ldb file disappear? I tried using db.close before setting db to newDB but came up with errors from some background timers.
2. How can I refresh my whole program so that it points to the new database file?
Jeff