"No such table" error

siddsg

Member
Licensed User
Longtime User
Hello,
I am using the DBUtils modules, and have an existing database that I am trying to query.
However, am getting the "no such table" error.
android.database.sqlite.SQLiteException: no such table: QueriesTable: , while compiling: SELECT Question FROM QueriesTable where NumQry = 1
Could you please help? Thanks so much!
1. I Attached the db file thru the Files tab.
2. Below is my code...

B4X:
Sub Process_Globals
    DimSQL1AsSQL
    DimDBFileDirAsString : DBFileDir = File.DirRootExternal ': DBFileDir = File.DirDefaultExternal
    DimDBFileNameAsString : DBFileName = "QueriesDB.db"
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        SQL1.Initialize(DBFileDir, DBFileName, True)
    End If
    Activity.LoadLayout("BasicCards")
    cdb.Initialize(Colors.LightGray,5)
    Activity.Background = cdb
    ScreenInit
End Sub
Sub btnBegin_Click
        WebViewDisplay.LoadHtml(DBUtils.ExecuteHtml(SQL1, "SELECT Question FROM QueriesTable where Qry_Id = 1", Null, 0, False))
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
How are you coping the database from File.DirAssets (files tab) to File.DirRootExternal?

You have created an empty database with this line:
B4X:
SQL1.Initialize(DBFileDir, DBFileName, True)

Delete the file and then use DBUtils.CopyDBFromAssets method to copy the database to a writable folder:

B4X:
If FirstTime Then

 DBFileDir = DBUtils.CopyDBFromAssets(DBFileName)

 SQL1.Initialize(DBFileDir, DBFileName, False)

End If
 
Upvote 0

siddsg

Member
Licensed User
Longtime User
That worked! :)
Thanks so much for the very quick response!
 
Upvote 0
Top