Ariel Constenla-Haile wrote:
Hi Drew,
Drew Jensen escribió:
Ariel Constenla-Haile wrote:
Drew Jensen escribió:
Hi,
I am hoping someone can help with this.
Need to open a ( execute ) a query from a Basic script.
Not sure if I am on the right track -
aconnection.queries.getByName( <queryName >)
That gets me the query definition and this has the function
execute so
aconnection.queries.getByName( <queryName >).execute( <parameters>)
1 ) Am I going about this correctly?
2) If so could really use some help on setting up the paramters
for the execute function.
Thanks in advance
Drew
Hi Drew,
if I understood you, you are trying to open the UI for "seeing" a
query,
just as if you double-clicked on a query name on the main application
window, am I wrong?
Here I correct myself:
If yes, you have to try
this is for opening the QueryDesign:
http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/QueryDesign.html
A very bad example:
Sub Main
Dim aProps(1) as New com.sun.star.beans.PropertyValue
aProps(0).Name = "DataSourceName"
aProps(0).Value = "Bibliography"
aProps(1).Name = "QueryDesignView"
aProps(1).Value = true
oComp =
StarDesktop.loadComponentFromURL(".component:DB/QueryDesign",
"_blank", 0, aProps)
End Sub
For opening the query, executing it, you have to try
http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/DataSourceBrowser.html
The components you see inside a frame in Writer/Calc when pressing
F4, and the onwe when you open a table/view/query, are the same.
How it works? Never tried :-(
In a simple/dummy test I could open it, BUT with the tree on the left.
Seems you'll have to learn it all by yourself, because - AFAIK -
there are no samples showing how to use all these API (another
"where is Base?" ).
Regards
Ariel.
Thanks...I know I am getting close and your example helps..
When I am done there will be at least one good example - I hope.
I spent pretty much all day yesterday putting together an overview
and set of Basic examples for working with the
SingleSelectQueryComposer and will be uploading that in just a bit -
this last piece would be a nice addition...not to mention it is being
called for by a couple of users.
looking at
http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/ContentLoader.html
seems like there is an URL for every UI element in OOo Base:
# .component:DB/DataSourceBrowser
Using this URL creates an instance of the DataSourceBrowser service
and plugs it into the frame passed to the loader.
# .component:DB/FormGridView
Using this URL creates an instance of the ExternalSourceBrowser
service and plugs it into the frame passed to the loader.
# .component:DB/QueryDesign
Using this URL creates an instance of the QueryDesign service and
plugs it into the frame passed to the loader.
# .component:DB/TableDesign
Using this URL creates an instance of the TableDesign service and
plugs it into the frame passed to the loader.
# .component:DB/RelationDesign
Using this URL creates an instance of the RelationDesign service
and plugs it into the frame passed to the loader.
this, together with the fact that we can open every form/report
without opening the ODB, seems to answer what some user were asking
for: to access the ODB from the Desktop without needing to open it.
IMO this already possible using the actual API.
The "problem" is learn how to use it ;-)
As the description says
"Usually, you don't deal with this loader directly. Instead it is
registered for a particular URL scheme, and you use the dispatch
mechanism provided by the application framework, dispatching URLs the
loader is registered for."
I think the road to follow is querying a dispatch object for this
command URL, and then calling dispatch() on the returned object,
passing the arguments specified in every service in that call.
That is, XComponentLoader::loadComponentFromURL() seems not to be the
proper one (although it works...)
Something like:
Sub Test
oDesktop = createUnoService("com.sun.star.frame.Desktop")
Dim aURL as New com.sun.star.util.URL
aURL.Complete = ".component:DB/DataSourceBrowser"
oDispatchObject = oDesktop.queryDispatch(_
aURL, _
"DataSourceBrowser_Frame",_
com.sun.star.frame.FrameSearchFlag.CREATE)
Dim aProps(2) as New com.sun.star.beans.PropertyValue
aProps(0).Name = "DataSourceName"
aProps(0).Value = "Bibliography"
aProps(1).Name = "CommandType"
aProps(1).Value = com.sun.star.sdb.CommandType.TABLE
aProps(2).Name = "Command"
aProps(2).Value = "biblio"
oDispatchObject.dispatch(aURL, aProps)
End Sub
Regards
Ariel.
Closer - I must admit your example makes for an interesting desktop,
with the datasource browser as a free floating window.
Anyway - slight change.
Sub Test( aQueryName as string, aConnection as variant )
oDesktop = createUnoService("com.sun.star.frame.Desktop")
Dim aURL as New com.sun.star.util.URL
aURL.Complete = ".component:DB/QueryDesign"
oDispatchObject = oDesktop.queryDispatch(_
aURL, _
"_BLANK",_
com.sun.star.frame.FrameSearchFlag.CREATE)
Dim aProps(2) as New com.sun.star.beans.PropertyValue
aProps(0).Name = "ActiveConnection"
aProps(0).Value = aConnection
aProps(1).Name = "CommandType"
aProps(1).Value = com.sun.star.sdb.CommandType.QUERY
aProps(2).Name = "Command"
aProps(2).Value = aQueryName
oDispatchObject.dispatch(aURL, aProps)
End Sub
Now when I call this from a button click on a open form - I get a query
design window opend on the desktop - SQL view mode - connected to the
same database as the form ( meaning I can add tables from the database
now - but the existing query definition is not loaded...)
little steps as they say...
thanks
Drew
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]