iOS Question Method not found: ExecQuery

gerredtor

Active Member
Licensed User
Hello i becom an Error on execute a SQL command:

B4X:
Error occurred on line: 70 (mysql)
Method not found: ExecQuery:, target: [_sql=[_sql=[_sql=[_sql=[_sql=[_sql=[_sql=[_sql=[_sql=, _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>], _speak=2, _main=<b4i_main: (null)>
, _httputils2service=<b4i_httputils2service: (null)>]
Stack Trace: (
  CoreFoundation       <redacted> + 150
  libobjc.A.dylib      objc_exception_throw + 38
  CoreFoundation       <redacted> + 0
  Lulaj                +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 426
  Lulaj                -[B4IShell runMethod:] + 574
  Lulaj                -[B4IShell raiseEventImpl:method:args::] + 1998
  Lulaj                -[B4IShellBI raiseEvent:event:params:] + 1442
  Lulaj                +[B4IDebug delegate:::] + 52
  Lulaj                -[b4i_dboptions _gettracklist::] + 424
  Lulaj                -[b4i_main _setuppage2advenced] + 1348
Lulaj                -[b4i_main _clv1_itemclick::] + 1144
CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 292
Lulaj                +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
Lulaj                -[B4IShell runMethod:] + 574
Lulaj                -[B4IShell raiseEventImpl:method:args::] + 2212
Lulaj                -[B4IShellBI raiseEvent:event:params:] + 1442
Lulaj                -[B4ICommon CallSub4::::] + 332
Lulaj                -[B4ICommon CallSub3:::::] + 392
Lulaj                -[b4i_customlistview _panel_click:] + 2196
CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 292
Lulaj                +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
Lulaj                -[B4IShell runMethod:] + 574
Lulaj                -[B4IShell raiseEventImpl:method:args::] + 2212
Lulaj                -[B4IShellBI raiseEvent:event:params:] + 1442
Lulaj                __33-[B4I raiseUIEvent:event:params:]_block_invoke + 74
libdispatch.dylib    <redacted> + 10
libdispatch.dylib    <redacted> + 22
libdispatch.dylib    _dispatch_main_queue_callback_4CF + 1532
CoreFoundation       <redacted> + 8
CoreFoundation       <redacted> + 1590
CoreFoundation       CFRunLoopRunSpecific + 516
CoreFoundation       CFRunLoopRunInMode + 108
GraphicsServices     GSEventRunModal + 160
UIKit                UIApplicationMain + 144
Lulaj                main + 108
libdyld.dylib        <redacted> + 2
)

and here my code:

B4X:
Sub Class_Globals
    Public sql As SQL 
End Sub

Sub createTable(db As String)
    If db.EqualsIgnoreCase("tracks") Then
        'Füllen
    End If
    If db.EqualsIgnoreCase("playlist") Then
        sql.ExecNonQuery("CREATE TABLE IF NOT EXISTS `playlist` (`id` INTEGER Not Null PRIMARY KEY AUTOINCREMENT, `trackID` INTEGER);")
    End If
    If db.EqualsIgnoreCase("favorites") Then
        sql.ExecNonQuery("CREATE TABLE IF NOT EXISTS `favorites` (`id` INTEGER Not Null PRIMARY KEY AUTOINCREMENT, `trackID` INTEGER);")
    End If
    If db.EqualsIgnoreCase("settings") Then
        'füllen
    End If
End Sub

Public Sub Initialize(db As String)
    If db.EqualsIgnoreCase("tracks") Then
        sql.Initialize(File.DirDocuments,"database.sqlite",True)
        createTable(db)
    End If
    If db.EqualsIgnoreCase("playlist") Then
        sql.Initialize(File.DirDocuments,"playlist.sqlite",True)
        createTable(db)
    End If
    If db.EqualsIgnoreCase("favorites") Then
        sql.Initialize(File.DirDocuments,"favorites.sqlite",True)
        createTable(db)
    End If
    If db.EqualsIgnoreCase("settings") Then
        sql.Initialize(File.DirDocuments,"settings.sqlite",True)
        createTable(db)
    End If
End Sub

Public Sub my_sql_load_wert(table As String, index As String, indexwert As String, suche As String) As String
    Dim rs As ResultSet
    rs = sql.ExecQuery("SELECT * FROM `"+table+"` WHERE `"+index+"`='"+indexwert+"'")
 
    If rs.NextRow = True Then
        Return rs.GetString(suche)
    End If
 
    Return Null
End Sub

Public Sub my_sql_new_wert(table As String, index As String, indexwert As String) As Int
    Dim rs As ResultSet
    rs = sql.ExecQuery("INSERT INTO `"+table+"` (`"+index+"`) VALUES ('"+indexwert+"')")
 
    Return rs.ColumnCount
End Sub

Public Sub my_sql_update_wert(table As String, index As String, indexwert As String, update As String, updatewert As String)
 
End Sub

Public Sub my_sql_exists_wert(table As String, index As String, indexwert As String)
 
End Sub

Public Sub ExecNonQuery(s As String)
    sql.ExecNonQuery(s)
End Sub

Public Sub ExecMysqlQuery(s As String) As ResultSet
    Dim rs As ResultSet = sql.ExecQuery(s)
    Return rs
End Sub

Sub CStr(o As Object) As String
Return "" & o
End Sub

Sub CInt(o As Object) As Int
  Return Floor(o)
End Sub

Sub CLng(o As Object) As Long
  Return Floor(o)
End Sub

Line 70 is:

B4X:
Dim rs As ResultSet = sql.ExecQuery(s)

And the execute:

B4X:
Public Sub getTrackList(name As String) As List
   Dim l As List
   l.Initialize()
   
   Dim rs As ResultSet
   rs = sql.ExecMysqlQuery("SELECT * FROM `categorie-translations` WHERE `speakID`='2' AND `categorieID` = '8'")     
   Do While rs.NextRow == True
     Try
       l.Add(rs.GetString("text"))
     Catch
       Log(LastException)
     End Try
   Loop
   
   Return l
End Sub
 
Last edited:

gerredtor

Active Member
Licensed User
B4X:
Public Sub ExecMysqlQuery(s As String) As ResultSet
    Dim rs As ResultSet = sql.ExecQuery(s)
    Return rs
End Sub

This is ExecMysqlQuery, he dont find ExecQuery
 
Upvote 0

gerredtor

Active Member
Licensed User
The class with the ExecMysqlQuery is "mysql"

dboptions:

B4X:
Sub Class_Globals
    Dim sql As mysql
End Sub

Public Sub Initialize(db As mysql)
    sql = db
End Sub

and in the main class:

B4X:
Dim sql As mysql
sql.Initialize("tracks")

Dim ops As dboptions
ops.Initialize(sql)
 
Upvote 0
Top