I never used macros before.
I googled a lot, and I was able to write this:
Code: Select all
Sub Main
DBContext=createUnoService("com.sun.star.sdb.DatabaseContext")
If not DBContext.hasByName("testdb") then
MsgBox ("Connection failed!" , "Error!") : End
End If
DataSource=DBContext.getByName("testdb")
ConnectToDB=DataSource.GetConnection ("","")
SQLResult=createUnoService("com.sun.star.sdb.RowSet")
SQLQuery="SELECT ""ID"", ""JBRTR"", ""OZB"" FROM ""testtable"""
SQLResult.activeConnection=ConnectToDB
SQLResult.Command=SQLQuery
SQLResult.execute
SQLResult.Last
Rows=SQLResult.getRow
Do
RandomID=Int(Rnd()*Rows)
SQLResult.Absolute(RandomID)
JeBrTrans=SQLResult.getString(2)
OzBa=SQLResult.getString(3)
Loop While isEmpty(JeBrTrans)
msgBox( JeBrTrans & " , " & OzBa )
ConnectToDB.close
ConnectToDB.dispose()
End Sub
But I'm TOO STUPID to put those results in textBoxes on same form from where I click on Button.
I really tried to do it myself, but without any success.
So, if anyone is merciful enough to tell me what is exact code I'm unable to figure out.
Thank you. Thank you very much.