BASIC+Calc+HSQLDB: How to move registered database
From the code:
Option Explicit
Function ConnectDatabase(dbFilename As String) As Object
Dim dbContext As Object : dbContext = createUNOService("com.sun.star.sdb.DatabaseContext")
Dim oDataSource As Object : oDataSource = dbContext.GetByName(dbFilename)
ConnectDatabase = oDataSource.GetConnection("","")'>>("Username","Password")
End Function
Sub TestDatabase
Dim db As Object
db = ConnectDatabase("LibreOfficeCalcSampleCodes_HSQLDB")
MsgBox "Connection completed"
DisconnectDatabase(db)
MsgBox "Disconnection completed"
End Sub
Initially , registered LibreOfficeCalcSampleCodes_HSQLDB.odb
was in folder /home/fedora002/Documents
and the database could be connected.
Then, I moved the database to subfolder /home/fedora002/Documents/BASICMacro
temporarily.
And finally I moved the database back to the initial folder /home/fedora002/Documents
.
There was an error message:
Why can't the registered database be moved to other folders even when it was moved back to the initial folder ?
| Fedora 31 Workstation KDE Desktop Spins | LibreOffice 6.2.8.2-2 |
The error states Basic can not find such
LibreOfficeCalcSampleCodes_HSQLDB
name in registered DB names list. Maybe some misspelling in DB name while moving? Also check if the name is in registered DB list.