Re: How to pass password when opening DatasourceBrowser
Frank Schönheit <[email protected]> Fri, 01 Oct 2010 09:08:26 +0200
| Newsgroups | gmane.comp.openoffice.dba.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Fernand,
> For opening a DataSourceBrowser I use following code
>
> Dim aProps(6) as New com.sun.star.beans.PropertyValue
> aProps(0).Name = "DataSourceName"
> aProps(0).Value = "mysql_native"
> aProps(1).Name = "CommandType"
> aProps(1).Value = 2 ' 0 = tabel , 1 = query , 2 = SQL statement
(I always recomment using com.sun.star.sdb.CommandType.* here, for
better readability of your code)
> aProps(2).Name = "Command"
> aProps(2).Value = "SQL statement"
> aProps(3).Name = "ShowTreeView"
> aProps(3).Value = false
> aProps(4).Name = "ShowTreeViewButton"
> aProps(4).Value = false
(note that ShowTreeView/Button are superseded (though still supported)
by Enable/ShowBrowser -
http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/DataSourceBrowser.html#XInitialization)
> aProps(5).Name = "ShowMenu"
> aProps(5).Value = true
> aProps(6).Name = "EscapeProcessing"
> aProps(6).Value = false
> oDataSourcebrowser =
> frame1.loadComponentFromURL(".component:DB/DataSourceBrowser",
> "_beamer", 0, aProps)
>
> That works fine excepted that the user is asked for a "Username" and
> "Password" when the datasource is opened !
>
> How can i avoid this behaviour by passing the "username and "password"
> within my code ?
> I tryed to use a "ActiveConnection" where the Username and password are
> passed... no luck
Hmm - I copied your code snipped, and added an "ActiveConnection"
parameter to aProps, containing an already established connection - this
worked like charm, as expected.
Sure you passed the right object, did not dispose it meanwhile, and the
like?
> Neither "UserName" or "Password" are accepted as arguments ....
No, those are indeed not supported.
> thanks for any hint
The ActiveConnection is the way to go, and it usually works - not sure
what you do differently, sorry.
Ciao
Frank