OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Automating Base application start-up for end users
Goto page Previous  1, 2
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
Dimitri44
General User
General User


Joined: 30 May 2008
Posts: 24

PostPosted: Fri Dec 18, 2009 4:27 am    Post subject: Reply with quote

Hi All,

Trying to put into practice this automation, using the code provided by Voo, I have encountered following problem: After restarting my computer, I found out that non of the modifications and/or new records have been stored in the database.
What I have done so far:
1. I have created a form inside the base and after that I have stored it on the Desktop (“Employments_1_1”). The form contains only one button (“Enter”), aimed to open the “Switchboard” form I've created and that resides inside base.
2. I have created a connection to my database, defining the corresponding data source.
3. In the “when initiating” event of the button, I have assigned following macro, provided by Voo:
Code:

sub OpenFormSwitchboard
   sFormName = "SwitchBoard"
   OpenForm( getFormsTC, getConnectionTC, sFormName )
end sub

function OpenForm( formContainer as variant, oConnection as variant, sFormName as string) as variant
Dim aProp(1) As New com.sun.star.beans.PropertyValue
aProp(0).Name = "ActiveConnection"
aProp(0).Value = oConnection
aProp(1).Name = "OpenMode"
aProp(1).Value = "open"

OpenForm = formContainer.loadComponentFromURL(sFormName,"_blank",0,aProp())
end function

function getFormsTC() as variant
   dim Context as object
   dim DB as object
   dim conn as object
         Context=CreateUnoService("com.sun.star.sdb.DatabaseContext")
         DB=Context.getByName("ΠΡΟΣΛΗΨΕΙΣ_1_1")
         Conn=DB.getConnection("","")
getFormsTC = conn.parent.databasedocument.getFormDocuments
end function

function getConnectionTC() as variant
   getConnectionTC = thisComponent.Drawpage.Forms(0).ActiveConnection
end function

Everything seems to work excellent, even I close the database and re-open it. All modifications and new records are saved in the corresponding tables. But when I restart me computer, no one of these modifications and new records are present!!!


What am I missing?

(Windows XPpro, OpenOffice 3.1)

Any suggestion will be highly appreciated!

Thank you very much in advance!

Dimitris
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Fri Dec 18, 2009 4:51 am    Post subject: Reply with quote

Hello

You describe a problem with data. that have nothing to do with your code.

When you have a great database then don't use the embedded HSQLDB but use the forms separated from yourdata.

see [url=http://www.oooforum.org/forum/viewtopic.phtml?t=92192 ]here[/url].

Romke
Back to top
View user's profile Send private message
Dimitri44
General User
General User


Joined: 30 May 2008
Posts: 24

PostPosted: Fri Dec 18, 2009 5:29 am    Post subject: Reply with quote

Dear Romke,

Thank you for your response.

The problem is the code which is used to communicate with the database from a form stored outside the database.
If I skip this art of communication, I mean if I will not use this procedure to approach the database via a form stored outside of it, all modifications are stored permanently in the database.

Thank you again

Dimitris
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Fri Dec 18, 2009 5:40 am    Post subject: Reply with quote

Hello

You use switchboard. Do you have the problems with switchboard of Benitez?
Is the data of the switchboard design not stored?

if both yes read manual: data must be stored explict

Romke
Back to top
View user's profile Send private message
Dimitri44
General User
General User


Joined: 30 May 2008
Posts: 24

PostPosted: Fri Dec 18, 2009 6:09 am    Post subject: Reply with quote

Hello Romke,

No, I don't use the Switcboard extension from Benitez.

"Switchboard" in my case is the name of the form I have created inside Base and I use it to open other forms stored also inside Base.
The name of the form that I use to open the aforesaid "Switchboard" and which is stored on the Desktop, is "Employments_1_1" and I'm facing no any problem with this form.

Thank you for the time you spend regarding my problem!

Dimitris
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Fri Dec 18, 2009 9:44 am    Post subject: Reply with quote

Hello

I still have the meaning that the code is not the reason of lossing data!
I understand you have your own switchboard.
Maybe you use the code in a wrong way. You open the database but do not close and store the new data.


If you explicit store the data with

CHECKPOINT DEFRAG

or

SHUTDOWN SHUTDOWN

Do you then loose your data?

The reason why you loose data can maybe; that you do not close the database with a good method. When you close the database then the data is written to the disk in the zipcontainer. Maybe when have your data separated then the problem is maybe over.


database container
OOo store all data of the database in one zipcontainer. When you open the database then internal, I don't know how, the data is separated from forms etc and the data. When you close the database then all thing are stored in the database container. I think in this last part you get the error. But this is outside my knowledge. But if you close the database in the good way I think your data is also stored.


Romke
Back to top
View user's profile Send private message
Dimitri44
General User
General User


Joined: 30 May 2008
Posts: 24

PostPosted: Fri Dec 18, 2009 1:26 pm    Post subject: Reply with quote

Dear all,

EUREKA!!!

I have managed the problem, using the following macro:
Code:

Sub CloseDatabase
   DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
   DataSource = DatabaseContext.getByName("My_Database_Name")
   Connection = DataSource.GetConnection("","")
   DataSource.flush
   Connection.flush
   'Statement = Connection.createStatement()
   'execute_sql = Statement.execute("SHUTDOWN COMPACT")   
   'execute_sql = Statement.execute("CHECKPOINT DEFRAG")
End Sub

In the form which is on Desktop, I have created a new button named “Save Changes” and I have assigned above macro to its “When initiating” event. Now all changes are stored permanently in the database!!!

Dear Romke,

As you can see in the code above, I have tried to solve the problem using your hints but with no result.
Using the flush() method from Java, although it is not documented in the HSQL documentation, I have managed to solve the problem.
Thank you very much for your interest and for the time you spent trying to help me.

Dimitris
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Fri Dec 18, 2009 1:44 pm    Post subject: Reply with quote

Hello

Nice you found the solution and also give it.

I was also searching but could not find it.

Thank you

Romke
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group