The app is connected to some local sqlite database files.
I am copying a table from one database file to another with this code
main=DBM1
fLoc=DBM2.DatabaseFile.NativePath
sql=“ATTACH DATABASE '”+fLoc+“’ AS B_alias”
OK=DBExecute(sql,“winWelcome.pbNewEvent.Pressed”)
if OK then
sql=“INSERT INTO B_alias.HandlerDog SELECT * FROM main.HandlerDog”
OK1=DBExecute(sql,“winWelcome.pbNewEvent.Pressed”)
end if
DBExecute method is simple:
DBM1.BeginTransaction
DBM1.ExecuteSQL(sql)
DBM1.CommitTransaction
return true
At the CommitTransaction I get the database is locked error.
EDIT: Didn’t do it exactly as OP suggested but his idea solved the problem. Here is a simplified version of what works for me.
main=DBM1
fLoc=DBM2.DatabaseFile.NativePath
try
sql=“ATTACH DATABASE '”+fLoc+“’ AS B_alias”
main.ExecuteSQL(sql)
sql=“INSERT INTO B_alias.HandlerDog SELECT * FROM main.HandlerDog”
main.ExecuteSQL(sql)
sql=“INSERT INTO B_alias.Teams SELECT * FROM main.Teams”
main.ExecuteSQL(sql)
sql=“DETACH DATABASE B_alias”
main.ExecuteSQL(sql)
MessageBox “Please review the handler/dog information for any changes since last event (month).”
catch DatabaseException
if DatabaseException.Message.Contains(“unique”) then
MessageBox “It appears that this event (month) is already started.”
else
MessageBox “There was an error transferring the team and handler/dog information to the new event database. Contact the author for help.”
end if
end Try