iOS Question Error Aquiring Lock

hwatech

Member
Licensed User
I'm having trouble finding an article in the forum relating to this issue... I'm trying to make a simple db query in b4i 5.51 to fill a b4xcombobox and I am getting the following error:

Application_Start
Error occurred on line: 46 (common)
Error acquiring lock. Make sure that all transactions are closed.
Stack Trace: (
CoreFoundation __exceptionPreprocess + 331
libobjc.A.dylib objc_exception_throw + 48
CoreFoundation +[NSException raise:format:] + 197
dbtest1 -[B4ISQL getLock] + 147
dbtest1 -[B4ISQL ExecQuery2::] + 68
dbtest1 -[b4i_common _fillcombo:] + 496
dbtest1 -[b4i_common _initialize:::] + 1083
CoreFoundation __invoking___ + 140
CoreFoundation -[NSInvocation invoke] + 325
dbtest1 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1672
dbtest1 -[B4IShell runMethod:] + 401
dbtest1 -[B4IShell raiseEventImpl:method:args::] + 2373
dbtest1 -[B4IShellBI raiseEvent:event:params:] + 1625
dbtest1 __33-[B4I raiseUIEvent:event:params:]_block_invoke + 51
libdispatch.dylib _dispatch_call_block_and_release + 12
libdispatch.dylib _dispatch_client_callout + 8
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1276
CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
CoreFoundation __CFRunLoopRun + 2310
CoreFoundation CFRunLoopRunSpecific + 626
GraphicsServices GSEventRunModal + 65
UIKitCore UIApplicationMain + 140
dbtest1 main + 112
libdyld.dylib start + 1
??? 0x0 + 1
)
Application_Active


If I eliminate the call to the sql.ExecQuery(...) the UI part of the program runs fine, so I'm certain it has to do with the calls to the database.

I am copying the dbtest1.db from dirassets to dirdocuments using the following:

Sub CopyDBIfNeeded (Filename As String)
If File.Exists(File.DirDocuments, Filename) = False Then
File.Copy(File.DirAssets, Filename, File.DirDocuments, Filename)
End If
End Sub

then executing the following before executing a query:

Initialize(Page1.RootPanel)
sql.Initialize(File.DirDocuments, "dbtest1.db", False)

I'm using a local Build Server 5.50

Any help would be appreciated
 

hwatech

Member
Licensed User
Sorry, first time posting, I should have read the first timers doc...

I just copied an example and this is the first resultset in the program. I'm probably missing something simple but it all works on the Android side. I did verify that the database file is there and the initialize statement seems fine

Here is the where it's crashing

B4X:
Sub fillccombo
    Dim data As List


    data.Initialize
    Dim rs As ResultSet = sql.ExecQuery("SELECT DISTINCT YEAR FROM F_FLDATA ORDER BY YEAR DESC" )
'^^ crashes on this statement
    Do While rs.NextRow
        'data.Add(rs.GetString("YEAR"))
    Loop
    rs.Close
    yearcombo.SetItems(data)
    yearcombo.SelectedIndex=0
   
End Sub
 

hwatech

Member
Licensed User
Thank You, and I was wrong, it wasn't working correctly on the android side. I introduced the common module once I went to b4i, I was doing the initialize in the main because I used DirInternal on the android side and needed to use DirDocuments on the iOS side and I wanted to keep the common module exactly the same for both apps
 

hwatech

Member
Licensed User
I see that DirInternal and DirDocuments are just strings so I can still make it global if I need to

Thanks Again
 

techknight

Well-Known Member
Licensed User
Thank You, and I was wrong, it wasn't working correctly on the android side. I introduced the common module once I went to b4i, I was doing the initialize in the main because I used DirInternal on the android side and needed to use DirDocuments on the iOS side and I wanted to keep the common module exactly the same for both apps
you can use #IF B4I and #IF B4A Statements.
 

hwatech

Member
Licensed User
Thanks to both of you,

yeah, I found the XUI.DefaultFolder, that's just what I needed, I'm still pretty new to B4X/XUI but I'm picking it up fast
 
Top