iOS Question Problems with merging two db3 files

Similar threads

B4i Tutorial Files and Folders
B4i Question Using SQLite
B4i Question DB3 not working in release?
B4i Question Slow FTP Upload
B4i Tutorial Reading and Writing PDF Documents


Licensed User
So I am currently working on a b4i app that is having some issues when trying to merge two db3 files. The files are supposed to merge by downloading the latest file from a server and then migrating the data from that new file to the old one. However since changing how files are downloaded an error keeps occurring when trying to migrate the data about how the tables in one of the db3 files doesn't exist but they should as the files are pretty much the same. and I was wondering if anybody would be able to help me figure out what could be causing this.

Here is the output from the console:

DB Error: 1 "no such table: Status"
DB Query: Drop Table [Status]
DB Path: /var/mobile/Containers/Data/Application/FCDAB994-C7B7-48DF-83B0-46BBAFB6B7E3/Documents/db_folder/data.db3
Here is the migration code:

Sub Migrate_Data_Import_New
If File.Exists(File.DirDocuments & "/" & Main.Corp_UserRef&"_db/",Main.corp_and_userref&"_1.db3") = True Then
    Dim txt As String

        If Main.SQL1.IsInitialized = True Then
            Main.SQL1.Initialize(File.DirDocuments & "/" & Main.Corp_UserRef&"_db/", Main.corp_and_userref&".db3", False)
            Log("sql initi")
        End If
Dim no As NativeObject = Main.sql1
        Dim cSQLAttach As String

cSQLAttach = "ATTACH DATABASE '" & File.Combine(File.DirDocuments & "/" & Main.Corp_UserRef&"_db/",Main.corp_and_userref&"_1.db3") & "' AS 'TRANSFER_TEMP'"

no.RunMethod("ExecNonQueryInsideTransaction::", Array(cSQLAttach, Null))

Dim TableName As String

TableName = "Status"
        txt="Drop Table ["&TableName&"] "
        Main.SQL1.ExecNonQuery(txt) ' this is where it crashes
        txt="CREATE TABLE ["&TableName&"] As Select * FROM TRANSFER_TEMP."&TableName
and Here is the new ftp code:

Public Sub Show_Import
db_filename = Main.corp_and_userref & ".db3"
    db_filename_migrate= Main.corp_and_userref & "_1.db3"

Main.FTP.Initialize("FTP",Main.FTP_IP, Main.FTP_Port, Main.FTP_Username, Main.FTP_Password)
    Main.FTP.PassiveMode = False
    If menu.force_import = True Then
Main.FTP.DownloadFile("//Incoming//"&db_filename,False,File.DirDocuments & "//" & Main.Corp_UserRef&"_db//",db_filename)
            Main.FTP.DownloadFile("//Incoming//"&db_filename,False,File.DirDocuments & "//" & Main.Corp_UserRef&"_db//",db_filename_migrate)
End If
I should also mention that the migrate sub is called in the FTP_DownloadComplete subroutine and that there is an b4a version of this app which uses a similar method as above and works fine



Licensed User
Could it just be that there is no Status table?
Dim tableExists As Int
tableExists = Main.SQL1.ExecQuerySingleResult($"SELECT count(*) FROM sqlite_master WHERE type='table' AND name='${TableName}'"$)
If tableExists > 0 Then
    txt="Drop Table ["&TableName&"] "
End If