Code
'Library1 Module1'
Option Explicit
Sub TestConnectingEmbeddedFirebird1
Dim iBox%
iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
On Local Error GoTo CloseConn
Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
MsgBox "Embedded Firebird database connected"
DisconnectDatabase(db)
MsgBox "Embedded Firebird database disconnected"
Else
MsgBox "No embedded Firebird database connected"
End IF
Exit Sub
CloseConn:
MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
DisconnectDatabase(db)
End Sub
Sub TestConnectingEmbeddedFirebird2
On Local Error GoTo CloseConn
Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
DisconnectDatabase(db)
Exit Sub
CloseConn:
MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
DisconnectDatabase(db)
End Sub
'Library2 Module1'
Option Explicit
Function ConnectDatabase(dbFilename$) 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 TestConnectingEmbeddedFirebird1
or Sub TestConnectingEmbeddedFirebird2
sent the error message:
How can we call Function in other Library (and in order to connect embedded Firebird database) ?