Problems with Active Connection

Using a split database, I am trying to run a text file containing an sql command using a push button in a form.

Here the macro:
sub dosql
if IsNull(ThisComponent.CurrentController.ActiveConnection) then
ThisComponent.CurrentController.connect
endif
txtfile="/home/xxxx/Desktop/sqls.txt"
f1 = FreeFile()
Open txtfile for Input as #f1

Do while NOT EOF(f1)
Line Input #f1, s
rem MsgBox(s)
oStatement = ThisComponent.CurrentController.ActiveConnection.createStatement()
oStatement.execute(s)
Loop
end sub

When I run this macro using the Tools, Macros, Run Macro command, it works.

However, when I assign this macro to a push button in a form. I get the following:

When I check to see if there is an active connection in the database by right clicking on the main screen on the Database connection I get this: Error code: 1000

The driver class ‘org.hsqldb.jdbcDriver’ could not be loaded.

Maybe that is part of the problem. Please excuse my ignorance.

Try this:

    if IsNull(Thisdatabasedocument.CurrentController.ActiveConnection) then
       Thisdatabasedocument.CurrentController.connect
    endif

Edit: Sorry but you will need to change you oStatement = also:

    oStatement = Thisdatabasedocument.CurrentController.ActiveConnection.createStatement()

s
If this answers your question please click on the :heavy_check_mark: (upper left area of answer).

Thank you, it worked. But nothing happened when I clicked the check mark. Hopefully it will change something.

@QuartoDie You are quite welcome. The check mark worked. It responds very slowly so patience is required.

You’re missing a period:

Is: The driver class ‘org.hsqldb.jdbcDriver’ could not be loaded.
Should be: The driver class ‘org.hsqldb.jdbc.Driver’ could not be loaded.