Sub OpenBaseShowQueryRun
Dim oConnection As Object
Dim oDatabaseContext As Object
Dim oDatabaseFile As Object
REM Dim oDataSource As Object
Dim oInteractionHandler as Object
Dim oQuery As Object
Dim oResult As Object
Dim oSQL_Statement As Object
Dim stQuery As String
oDatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
oDatabaseFile = oDatabaseContext.getByName("DataBase")
If Not oDatabaseFile.IsPasswordRequired Then
oConnection = oDatabaseFile.GetConnection("","")
Else
oInteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
oConnection = oDatabaseFile.ConnectWithCompletion(oInteractionHandler)
End If
oQuery = oDatabaseFile.getQueryDefinitions()
stQuery = oQuery.getByName("Query").Command
REM MsgBox stQuery
REM oConnection = oDatabaseFile.ActiveConnection()
oSQL_Statement = oConnection.createStatement()
oResult = oSQL_Statement.executeQuery(stQuery)
End Sub
This throws the error on oResult = oSQL_Statement.executeQuery(stQuery)
BASIC runtime error.
An exception has occurred
Type: co.sun.start.sdbc.SQLException
Message: parameter marker not allowed.
Could not find any info on it.
There are some REMs placed, due to the suspicion that they are not needed.
Leaving out âoSQL_Statementâ, âoResultâ, and remove âREMâ for âMsgBoxâ, the Macro does connect to the DataBase and again will show the content of the Query.
For your 2nd suggestion, I have to check further, but want to run the query and have the User provide input.
Dream