I have just started using LibreOffice Calc coming from Excel VBA.
I have managed to get a connection to my database using SQL, but I’m struggling to get the entire contents from the SQL results added to my active sheet.
The SQL results get 20 columns of data which I have limited to 10 records
In VBA I would have used something like this to enter the results into cell A1
Dim rs as recordset
Const strSQL = "SELECT * FROM owners LIMIT 10"
Set rs = conn.Execute(strSQL)
With ActiveSheet.QueryTables.Add(Connection:=rs, Destination:=Range("A1"))
.Refresh
End With
What can I use in LO to enter the all the data in rs into the sheet starting at position A1
My LO code is as follows:
Stmt=Conn.createStatement()
‘Create worksheet
Worksheets.Add(After :=Worksheets("README")).name = "Owners"
Set ws = wb.Sheets("Owners")
REM create an SQL command
strSQL="SELECT * FROM owners LIMIT 10"
rs = stmt.ExecuteQuery(strSQL)