Ask Your Question

Bear31's profile - activity

2020-07-02 07:57:04 +0200 received badge  Notable Question (source)
2020-07-01 05:40:13 +0200 received badge  Enthusiast
2020-06-29 23:58:32 +0200 commented answer How to make a ResultSet Read/Write

Thanks again @Ratslinger for your great advice. I've modified my code to use RowSet and now it works as I want. You've

2020-06-29 23:49:48 +0200 marked best answer How to make a ResultSet Read/Write

I have a DRAW document and BASE document. The BASE document has tables that contain data which relates to different shapes in the DRAW document.

I have written a macro that will display data related to a selected shape and display it in a Dialog.

Clicking the "Cancel button on the Dialog causes it to close, so all good up to that point.

I want to be able to edit the TextBoxes on the Dialog and then click the OK button to save the updated data back to the BASE document but when I try to do this I get an error message that the "Result Set is Read Only".

I've used MRI to examine the Connection to determine that it is Read/Write, but do not see a Read Only property for the Result Set.

I have manually tested the SQL statement in the BASE GUI and I can update the fields that way, so I think my SQL is OK.

The OOo BASIC Guide tells me there is a ResultSetConcurrency Variant that controls whether the Result Set can be modified (but doesn't go so far as to explain how to modify it). Using MRI I can see that ResultSetConcurrency is a number which is ReadOnly. I'm guessing that I need to set this value to something else, somehow, as part of the ExecuteQuery method. Half a day of looking through various documents and forums has not enlightened me :(

I've attached my Macro(s) that relate to the problem I'm stuck at, so perhaps someone can point me in the right direction (please!)
BTW - these macros are still in very early development, so maybe there is some fundamental flaw here somewhere.

Option Explicit

Global FibreDoc As Object
Global Connection As Object
Global DataSource As Object
Global DatabaseContext As Object
Global bPitSaveFlag as Boolean
Global oPitDialog as Object

Sub SetDefaults

    Dim InteractionHandler as Object

FibreDoc = ThisComponent
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("Fibre-data")

If Not DataSource.IsPasswordRequired Then
  Connection = DataSource.GetConnection("","")
Else
  InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
  Connection = DataSource.ConnectWithCompletion(InteractionHandler)
End If
'Connection.SetReadOnly(False)
'mri(Connection)
End Sub


Sub ShowPitDialog
      Dim oCurrentSelection As Variant
      Dim oPit As Variant
      Dim sPitName as String
      Dim iNameLength as Integer
      Dim iSepPos as Integer
      Dim iPitID as Integer
      Dim sPitSQL as String
      Dim sTypeSQL as String
  Dim oPitStatement as Object
  Dim oTypeStatement as Object
  Dim oResultSet as Object
  Dim oTypeResult as Object
  Dim oTypeList as Object
  Dim sTitle as String
  Dim iCount as Integer


   Globalscope.BasicLibraries.LoadLibrary( "MRILib" )

  If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then 
      GlobalScope.BasicLibraries.LoadLibrary("Tools")
  End If      

  bPitSaveFlag = False 'Indicator to save updated data

 'mri(Connection)

  oCurrentSelection = FibreDoc.getCurrentSelection()
  oPit = oCurrentSelection.getByIndex(0)
  sPitName = oPit.Name  'The name of the object that is selected
  iNameLength = len(sPitName)
  iSepPos = InStr(sPitName,":")  'Location of the separating ":" in the name
  iPitID = Right(sPitName,(iNameLength-iSepPos)) 'The number to the right of the separating ":"

  sPitSQL = "SELECT ""ID"", ""Lat"", ""Long"", ""Type"", ""Comments"" FROM ...
(plus)
2020-06-29 22:01:11 +0200 received badge  Popular Question (source)
2020-06-29 06:15:19 +0200 asked a question How to make a ResultSet Read/Write

How to make a ResultSet Read/Write I have a DRAW document and BASE document. The BASE document has tables that contain

2020-06-28 20:38:38 +0200 received badge  Notable Question (source)
2020-06-27 02:19:24 +0200 marked best answer BASIC example - get information about a selected shape on LibreOffice Draw

I'm trying to use LibreOffice BASIC to link data from a LibreOffice Base database, with shapes on a LibreOffice Draw document. I've made some progress accessing the data, but need to understand how I can determine which shape has been selected in the Draw document, then read some properties of that shape. I will then use the shape property to build a SQL statement to get the right data from the Base file. I'm finding this a very steep learning curve and though there is some useful information around, there is nothing I have found (yet) that shows me how to get the selected shape and read properties of it.

Any assistance (preferably and example Sub) would be greatly appreciated.

2020-06-27 02:19:24 +0200 received badge  Scholar (source)
2020-06-27 02:12:25 +0200 commented answer BASIC example - get information about a selected shape on LibreOffice Draw

Thanks @Ratslinger - that's the information I need. I have downloaded Andrew Pitonyak's resource along with a couple of

2020-06-26 20:58:45 +0200 received badge  Popular Question (source)
2020-06-26 07:28:54 +0200 asked a question BASIC example - get information about a selected shape on LibreOffice Draw

BASIC example - get information about a selected shape on LibreOffice Draw I'm trying to use LibreOffice BASIC to link d