Hi,

I'm not a Basic specialist but I guess you must close the DataSource at the end 
of program. Otherwise the behavior may be undefined. That's the way how it 
works in Java and I guess also Basic.

regards,
Oliver

Am 21.12.2010 um 13:16 schrieb listsandst...@freenet.de:

> Hello,
> 
> I am new to this list, hello everybody!
> 
> I've a problem with a Base-Application (Basic). See below for a codesample.
> 
> The code is adding a row to a database (Base-Document with embedded
> HSQL-DB) every time it gets called. However the changes are lost after
> closing OOO. To make them permanent it's necessary to flush() the
> DataSource.
> 
> First question: This is not exspected bahaviour, is it? Changes should
> be persistently saved without calling flush(), or am I wrong?
> 
> But the trouble gets worse... The flush() - workaround works fine on
> Linux (Using OOO 3.2.1 and 2.4 on Debian), but it crashes OOO 3.2.1 on
> Windows (XP) ungracefully.
> 
> Any ideas? Thanx a lot,
> Daniel
> 
> 
> REM  *****  BASIC  *****
> Option Explicit
> 
> REM Sub TestDB
> REM Inserts a new row into a database every time it is executed
> REM Requires a registered database called "test" with one column: "id"
> 
> Sub TestDB
>       Dim DBContext, DataSource, Connection As Object
>       Dim Statement, ResultSet As Object
>       Dim NrOfRows As Integer
>               
>       REM Establish database connection
>       DBContext = createUnoService("com.sun.star.sdb.DatabaseContext")
>       DataSource = DBContext.getByName("test")
>       Connection = DataSource.GetConnection("","")
> 
>       REM Insert a new row into database
>       Statement = Connection.createStatement()
>       Statement.executeUpdate("INSERT INTO ""test"" (""id"") VALUES (NULL)")
>       
>       REM Count rows in database, to check if insertion did work
>       ResultSet = Statement.executeQuery("SELECT COUNT(*) FROM ""test""")
> 
>       ResultSet.next
>       NrOfRows = ResultSet.getInt(1)
>       
>       REM Show result
>       MsgBox "Rows in database: " & NrOfRows
>       
>       REM The above code works, but changes to DB are not persistent.
>       REM That means: after closing OOO the added rows are lost
>       
>       REM Flushing the DataSource helps, but ... (see mail)
>       REM DataSource.flush()
> 
> End Sub
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
> For additional commands, e-mail: dev-h...@api.openoffice.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to