Making a copy of a database under program control.
Posted: Fri Feb 22, 2013 7:36 pm
The following code allows me to 'clone' the SQLite database I am currently using and then switch me to that database. It works on my Mac where I developed it but does not work on my PC. Any suggestions?
Thanks in advance,
Larry
Code: Select all
on cloneDatabase
global gConIDRadi
put the field "Database Name" into tCurrentDB
replace "_GR.db" with "" in tCurrentDB
put tCurrentDB into tOldDB
put "_Clone" after tCurrentDB
ask question "What would you like to name this 'cloned' database?" with tCurrentDB titled "Clone Database"
put it into tCurrentDB
If tCurrentDB is not empty then
if tCurrentDB = tOldDB then
answer Warning "Duplicate name not allowed." titled "Clone Database"
exit cloneDatabase
end if
put "_GR.db" after tOldDB
put "_GR.db" after tCurrentDB
put the directory into tPath
put slash after tPath
put "binfile:" & tPath & tOldDb into tOldFile
put "binfile:" & tPath & tCurrentDB into tNewFile
put URL(tOldFile) into URL(tNewFile)
put the result into tResult
If tResult is empty then
put tCurrentDB into field "Database Name"
refreshMenu
end if
end if
end cloneDatabase
Larry