Re: [api-dev] How to pass a connection to a Subform

2008-12-29 Thread Fernand Vanrie

Andrew,

Thanks for your reply, indeed I have to check all this load,  unload and 
reload stuff, I am on vavacation now and have no acces to the databases. 
I do this checks after newyear and come back with the results.

Have a Happy newyear for you and your Family

Fernand

Andrew Douglas Pitonyak schreef:
I have been trying to follow what you are doing and I am not sure that 
I really understand.


Usually, I have a base document that contains forms. The base document 
references a datasource (database) of some sort. I then have my forms 
reference that same database. For example:


sub subDisplayForm(sDatabaseName as string, sFormName as string)
 dim mArgs(1) as new com.sun.star.beans.PropertyValue

 oDatabase = fnGetOpenDatabase(sdatabaseName)
 oConnection = oDatabase.getConnection("","")
 mArgs(0).name = "OpenMode"
 mArgs(0).value = "open"'"openDesign"
 mArgs(1).name = "ActiveConnection"
 mArgs(1).value = oConnection
 oForm = oDatabase.getFormDocuments.getByName(sFormName)
 'oForm.visibilityChanged(true)
 oForm = oDatabase.getFormDocuments.loadComponentFromURL(sFormName, 
"_blank", 0, mArgs())

end sub


In this example, the connection is obtained from the database document 
so everything points to the database associated with the ODB document. 
I use those specific terms in case the real database is an external 
database such as MySQL.


Are you attempting to use a connection that points to a different 
database?


Now, I will take a look at what you have:


Fernand Vanrie wrote:
lets starts with geting a connection (here I make a connection to a 
odbc driver whos gives me acces to a MS SQL database)

   sURL = "sdbc:odbc:debiteuren"
   oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
   oCon = oManager.getConnection(sURL)


OK, so here, you clearly reference an external DB, one that is not 
even referenced by a Base document. No problem so far.


I have one native OO-basedocument with 2 Formdocs  who uses the same  
internal HSQL databse engine
the goal is to use Switchboard to give users acces to all my forms 
and keep them away from the databsestuff


You have a Base document that contains data. I assume that the schema 
in the Base document is the same as the external  database.


in Formdoc1 I have oForm who is the mainform for some Subforms who 
must/can use my "oCon"

in FormDoc2 I have oFom2 as a mainform who also must use my "oCon"

We can not uses "oCon" to set a ActiveConnection in a already opened 
form.

oForm.ActiveConnection = oCon  >gives a error (propertyVeto)
First we have to open a form with "loadComponentFromURL" who accept 
oCon as argument.


Now I have a "open" oform with right  "ActiveConnection" but the 
subforms  are  not knowing about this connection. The good news is 
that we can pass the "ActiveConnection" to the subforms

oSubForm.ActiveConnection = oForm.ActiveConnection
be carfull to check that the form is not opened in "designMode" the 
trick is only working when opened in "open" mode !!!


Let me repeat what you wrote to verify that I understand.

(1) You can use your external connection to load a form and the 
connection works as desired.


(2) The subforms do not use the external connection as desired, but 
you are able to directly set the sub forms to use the same connection 
as their parent.




BUT !it is tnot possible to passing my "oCon" to the  other 
oform2 who is located in a other fromdocument


oform2.activeConnection = oform.activeConnection   >gives a error 
(propertyVeto)


Now, you state that you can not change the connection on a main form 
if the form is already open.


Do you know who vetos the exception? Is it the DocumentDefinition?

Does the form have a "reload" method?

What happens if you call unload before setting the active connection 
and then calling load? How about calling reload then setting the 
active connection? Have you tried closing the connection that is used 
and then setting a new active connection?


These are all guesses, and you might have better luck asking on the 
dba forums (unless Frank hangs out here).






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



Re: [api-dev] How to pass a connection to a Subform

2008-12-27 Thread Andrew Douglas Pitonyak
I have been trying to follow what you are doing and I am not sure that I 
really understand.


Usually, I have a base document that contains forms. The base document 
references a datasource (database) of some sort. I then have my forms 
reference that same database. For example:


sub subDisplayForm(sDatabaseName as string, sFormName as string)
 dim mArgs(1) as new com.sun.star.beans.PropertyValue

 oDatabase = fnGetOpenDatabase(sdatabaseName)
 oConnection = oDatabase.getConnection("","")
 mArgs(0).name = "OpenMode"
 mArgs(0).value = "open"  '"openDesign"
 mArgs(1).name = "ActiveConnection"
 mArgs(1).value = oConnection
 oForm = oDatabase.getFormDocuments.getByName(sFormName)
 'oForm.visibilityChanged(true)
 oForm = oDatabase.getFormDocuments.loadComponentFromURL(sFormName, "_blank", 
0, mArgs())
end sub


In this example, the connection is obtained from the database document 
so everything points to the database associated with the ODB document. I 
use those specific terms in case the real database is an external 
database such as MySQL.


Are you attempting to use a connection that points to a different database?

Now, I will take a look at what you have:


Fernand Vanrie wrote:
lets starts with geting a connection (here I make a connection to a 
odbc driver whos gives me acces to a MS SQL database)

   sURL = "sdbc:odbc:debiteuren"
   oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
   oCon = oManager.getConnection(sURL)


OK, so here, you clearly reference an external DB, one that is not even 
referenced by a Base document. No problem so far.


I have one native OO-basedocument with 2 Formdocs  who uses the same  
internal HSQL databse engine
the goal is to use Switchboard to give users acces to all my forms and 
keep them away from the databsestuff


You have a Base document that contains data. I assume that the schema in 
the Base document is the same as the external  database.


in Formdoc1 I have oForm who is the mainform for some Subforms who 
must/can use my "oCon"

in FormDoc2 I have oFom2 as a mainform who also must use my "oCon"

We can not uses "oCon" to set a ActiveConnection in a already opened 
form.

oForm.ActiveConnection = oCon  >gives a error (propertyVeto)
First we have to open a form with "loadComponentFromURL" who accept 
oCon as argument.


Now I have a "open" oform with right  "ActiveConnection" but the 
subforms  are  not knowing about this connection. The good news is 
that we can pass the "ActiveConnection" to the subforms

oSubForm.ActiveConnection = oForm.ActiveConnection
be carfull to check that the form is not opened in "designMode" the 
trick is only working when opened in "open" mode !!!


Let me repeat what you wrote to verify that I understand.

(1) You can use your external connection to load a form and the 
connection works as desired.


(2) The subforms do not use the external connection as desired, but you 
are able to directly set the sub forms to use the same connection as 
their parent.




BUT !it is tnot possible to passing my "oCon" to the  other oform2 
who is located in a other fromdocument


oform2.activeConnection = oform.activeConnection   >gives a error 
(propertyVeto)


Now, you state that you can not change the connection on a main form if 
the form is already open.


Do you know who vetos the exception? Is it the DocumentDefinition?

Does the form have a "reload" method?

What happens if you call unload before setting the active connection and 
then calling load? How about calling reload then setting the active 
connection? Have you tried closing the connection that is used and then 
setting a new active connection?


These are all guesses, and you might have better luck asking on the dba 
forums (unless Frank hangs out here).


--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info:  http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html


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



Re: [api-dev] How to pass a connection to a Subform

2008-12-26 Thread Fernand Vanrie

OK i learned a bit more :

lets starts with geting a connection (here I make a connection to a odbc 
driver whos gives me acces to a MS SQL database)

   sURL = "sdbc:odbc:debiteuren"
   oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
   oCon = oManager.getConnection(sURL)
I have one native OO-basedocument with 2 Formdocs  who uses the same  
internal HSQL databse engine
the goal is to use Switchboard to give users acces to all my forms and 
keep them away from the databsestuff


in Formdoc1 I have oForm who is the mainform for some Subforms who 
must/can use my "oCon"

in FormDoc2 I have oFom2 as a mainform who also must use my "oCon"

We can not uses "oCon" to set a ActiveConnection in a already opened form.
oForm.ActiveConnection = oCon  >gives a error (propertyVeto)
First we have to open a form with "loadComponentFromURL" who accept oCon 
as argument.


Now I have a "open" oform with right  "ActiveConnection" but the 
subforms  are  not knowing about this connection. The good news is that 
we can pass the "ActiveConnection" to the subforms

oSubForm.ActiveConnection = oForm.ActiveConnection
be carfull to check that the form is not opened in "designMode" the 
trick is only working when opened in "open" mode !!!


BUT !it is tnot possible to passing my "oCon" to the  other oform2 
who is located in a other fromdocument


oform2.activeConnection = oform.activeConnection   >gives a error 
(propertyVeto)


are my assumptions correct or a i missing something ?

Thanks

Fernand








Fernand Vanrie wrote:

Here we arae again :-)

I can pass a new connection to a Form present in a base Doc using 
"loadComponentFromURL" where the nwe connection is passed as a 
argrument .  but  for the the SubForms present in this loaded Form i 
find no longer a "formcontainer who supports "loadComponentFromUR"  
and anyhow this forms are "loaded  but with no  Active connection or 
the Active connection who was present in the oriinal Base Doc. In 
other words the sub forms are not aware of the new connection in the 
main Form.


So: again  :-) how to change the activeConnection in a SubForm

Thanks for any hint

-
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