What does "Library routine call out of sequence" means?

Getting a message “Library routine call out of sequence.” Not sure why Im getting there error. Here is the code I’m using.

[code]Public Function OpenTaxTable(sDatabaseName as String) as Boolean
Dim bDBOpened As Boolean = False

dbTaxTableDir = GetFolderItem(App.LocalFoxieUpdatePath).Child(“TaxTables”)
If dbTaxTableDir <> Nil Then
If dbTaxTableDir.Exists And dbTaxTableDir.directory Then

  dbTaxTableFile = dbTaxTableDir.child(sDatabaseName)
  If dbTaxTableDir <> Nil Then
    
    dbTaxTable = New REALSQLdatabase
    dbTaxTable.DatabaseFile = dbTaxTableFile
    dbTaxTable.EncryptionKey = App.Toby
    
    If Not dbTaxTableFile.Exists Then
      If dbTaxTable.CreateDatabaseFile Then
        If dbTaxTable.Connect Then bDBOpened = True
        
      End If
    Else
      If dbTaxTable.Connect Then 
        bDBOpened = True
        If dbTaxTableFile.Locked Then dbTaxTableFile.Locked = False
      End If
      
    End If
  End If
  
End If

End If

MsgBox dbTaxTable.ErrorMessage
Return bDBOpened

'Dim bDBOpened As Boolean
'bDBOpened = False


'dbTaxTableDir = GetFolderItem(App.LocalFoxieUpdatePath).Child(“TaxTables”)
'If dbTaxTableDir <> Nil Then
'If dbTaxTableDir.Exists And Not dbTaxTableDir.directory Then
''not okay
'Elseif dbTaxTableDir.Exists And dbTaxTableDir.directory Then


'dbTaxTableFile = dbTaxTableDir.child(sDatabaseName)
'If dbTaxTableFile <> Nil Then
'If dbTaxTableFile.exists Then

'dbTaxTable = New REALSQLdatabase
'dbTaxTable.DatabaseFile = dbTaxTableFile
'dbTaxTable.EncryptionKey = App.Toby


'MsgBox dbTaxTableFile.absolutePath

'If dbTaxTable.Connect Then
'bDBOpened = True
'End If



'end if
'end if

'end if
'End If

'Return bDBOpened

End Function
[/code]

Anybody know why this is happening?

I suspect createdatabasefile, if it succeeds, leaves you connected & so you don’t need to call connect. But, I have not tested that. Just so you know, REALSQLdatabase was deprecated in 2013.

When stepping through the code its not executing that part. It finds the database but it does not connect to it. My boss isn’t ready to move on from REALSQLdatabase because it leaves the transactions open. We have a huge accounting program that is dependent on opening and closing the transaction and he’s not ready to move on yet.

Could you elaborate on that? Didn’t you have to call rollback or commit?

A RealSQLDatabase is basically a SQLiteDatabase – in fact all you have to do to modernize it is to rename it to *.sqlite and then open it as SQLite db which will bring you the benefits of a contemporary db engine.
Even if there were differences in transaction handling: If the code is somewhat structured, it should not be too much work to adapt it to a modern engine.

The name can be anything, with any extension. And I believe there have been some subtle changes to transaction handling, but that might just be a matter of the default changed, so you’d have to explicitly turn transactions on or off when you open the database.

Anybody know how to fix this?

Which line causes the issue?

As dbTaxTable is not a local variable, is it Nil before you use it here?