Android Question SQLite - trouble with ExecNonQueryBatch and SQL_NonQueryComplete

Jeff (Not 24)

New Member
Licensed User
Longtime User
I have a routine that I'm adding to my copy of DBUtil that I'll make available as soon as I'm done with it. It executes all the SQL statements that are in a txt file. But I have 2 problems:

1. When I also put a sub named SQL_NonQueryComplete(Success As Boolean)" in DBUtil along with my "ExecSQLCommandsFromFile" sub, then the "SQL_nonQueryComplete" isn't found. However, if I put the SQL_NonQuerComplete in the main module, it works fine. Is that the way it's supposed to work?

2. In my text file, if I have any blank lines or lines that are only comments (denoted by -- at the beginning of the line), then it seems to fail.

Thanks ... Jeff


B4X:
' Reads & executes a set of SQL Non-Query type commands from a file.
' Great For creating tables, views, complex indices, etc. in those cases In which you don't want to use the other DBUTIL commands.
' Uses standard SQL syntax.
Sub ExecSQLCommandsFromFile (SQL As SQL, fileDir As String, fileName As String)
  Dim List1 As List
  List1 = File.ReadList(fileDir, fileName)
  Log ("Reading Batch SQL Statements from " & fileDir & "/" & fileName)
  Log (List1.Size & " BATCH SQL STATEMENTS FOLLOW")
  For Each Cmd As String In List1
    Log(Cmd)
    SQL.AddNonQueryToBatch(Cmd,Null)
  Next
  Log ("BATCH SQL STATEMENTS END")
  SQL.ExecNonQueryBatch("SQL")
End Sub


B4X:
' NonQueryComplete is invoked by ExecSQLCommandsFromFile
Sub SQL_NonQueryComplete(Success As Boolean)
    Log("NonQuery: " & Success)
    If Success = False Then
        Log(LastException)
        Msgbox("BAD " & Success,"SQL ERROR")
    Else
        Msgbox("GOOD " & Success,"SQL IS FINE")
    End If
   
End Sub
 
Top