Rik,
Me again :-)
found a complete sub who works on HSQLDB but also not run from in the
BaseDoc itself
Sub SaveToDB (path as string)
oSrcFilePath = ConvertToUrl(path)
oFileAccessService = createUnoService("com.sun.star.ucb.SimpleFileAccess")
oTextInputStream = createUnoService("com.sun.star.io.TextInputStream")
oTextInputStream.setInputStream(oFileAccessService.openFileRead(oSrcFilePath))
'xray oTextInputStream
ss = oTextInputStream.readstring(array(),false)
oDatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
oDataSource = oDatabaseContext.getByName("ODF_test_PI")
oConnection = oDataSource.GetConnection("","")
' prepare the Statement
sSQL = "INSERT INTO TEST(HTML) VALUES(?)"
Statement = Oconnection.PrepareStatement(sSQL)
' insert ss for ( ? ) placeholder 1
Statement.setString(1,ss)
' write to Database ( Use iAccess to check Success if you want)
iAccess = Statement.executeUpdate()
print iAccess
if iAccess = 1 then
' oSimpleFileAccess.kill( path )
endif
sStatement = oconnection.createstatement
sSQL = "Select * from TEST where AUTO = 119"
sStatement.execute(sSQL)
resultset = sstatement.getresultset
resultset.next
' xray resultset
sHTML = resultset.getString(3)
InsertHTMLContent(sHTML)
End Sub
Rik,
normaly for a OO-Dbase connectyed to MYSQL i use
oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")
if not oDB.hasbyname("OODbaseName")then
oDB.registerDatabaseLocation("mOODbaseName",converttoURL("Path to
OODbasename.odb")
endif
oConn = oDB.GetByName("OODbaseName").GetConnection("User","Password")
Hope it helps
Fernand
Hello together,
I'm new here, and i have a serious problem with my Base DB with
embedded HSQLDB.
I'm not shure, if the problem exists 'cause of my Hard- and Software
combination or if it's a serious bug in Base.
Using OOo 3.3-Base, Windows 7 and tryed out JRE 1.6.0_20/22/24 the
problem exists with all of them:
When launching Openoffice.org BASE with embedded HSQLDB and directly
*open a form* or dialog *via basic macro*,
*all inserted and changed datas are lost on closing the database
document*.
That means, opening a Form in code does work, and I can see the datas
of the HSQLDB in the form.
They also can be changed. Reopening the form via code shows the
changed datas, i think they are written to cached tables, but not to
the hard disk.
By closing the database-document, all added or changed datas are lost.
With xray I found out, that there is no "activeConnection" into
HSQLDB established by opening forms or dialogs on this way.
When i change once into "Table view", then
"thisComponent.currentcontroller.activeConnection" can be seen with
Xray, otherwise it's a "Null Object".
In this case, all added and changed datas will be written to the
embedded HSQLDB, nothing lost.
Does anybody know, how to establish the "activeConnection" via Basic?
Rik Hustede
--
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help