Re: How to pass password when opening DatasourceBrowser
Fernand Vanrie <[email protected]> Fri, 01 Oct 2010 14:45:08 +0200
| Newsgroups | gmane.comp.openoffice.dba.devel |
|---|---|
| Message-ID | <[email protected]> |
Frank,
Found a work around:
I now passes the "password" to the com.sun.star.comp.dba.ODatabaseSource
password property
oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDB.GetByName("mysql_native").password = "mypassword"
and the databrowser opens silently with the data init.
but please (if you find two seconds) check if i did something wrong when
using the activeconnection
Thanks
Fernand
> Frank ,
>
> Are you sure you didn' tryed with user/password before you tryed the
> activeconnection, because OO remembers the connection made by
> user/password ?
>
> "stays empty"? If you pass an ActiveConnection to the DSB, then it stays
> empty, if you don't pass it, then it asks for user/password, and
> properly displays your table? Did I get this right?"
>
> yes thats wath happens, with table or SQL statement i do not tryed a
> query
>
> Irun on windows , OOO320m17 (3.2.1), Connector 1.0.0
>
> tryed connection Pooling ON and OFF, no difference
>
> The code who works but is asking for User and pasdword:
>
>
> Dim aProps(7) as New com.sun.star.beans.PropertyValue
> aProps(0).Name = "DataSourceName"
> aProps(0).Value = "mysql_native" ' deze "naam" moet dus
> GEREGISTREERD ZIJN als Database in OO
> aProps(1).Name = "CommandType"
> aProps(1).Value = 0
> aProps(2).Name = "Command"
> aprops(2).value = "pmgdbase.mag_news_export"
>
> The code who do not works :
>
> oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")
> oConn =
> oDB.GetByName("mysql_native").GetConnection("user","password")
> ' xray oconn
> Dim aProps(7) as New com.sun.star.beans.PropertyValue
> aProps(0).Name = "ActiveConnection"
> aProps(0).Value = oconn
> aProps(1).Name = "CommandType"
> aProps(1).Value = 0 ' 0 = tabel , 1 = query , 2 = SQL statement
> aProps(2).Name = "Command"
> aprops(2).value = "pmgdbase.mag_news_export
>
> Is there something wrong with the way is pass te oConn object ?? (when
> xraying everithings seems to be ok)
>
> Greetz
>
> Fernand
>
>>> Wath i already tryed en yet again tryed
>>>
>>> oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")
>>> oConn =
>>> oDB.GetByName("mysql_native").GetConnection("username","password")
>>>
>>> Dim aProps(7) as New com.sun.star.beans.PropertyValue
>>> aProps(0).Name = "ActiveConnection"
>>> aProps(0).Value = oconn
>>>
>>> but the browser stays empty ! ( i tryed with table and sql Statement)
>> "stays empty"? If you pass an ActiveConnection to the DSB, then it stays
>> empty, if you don't pass it, then it asks for user/password, and
>> properly displays your table? Did I get this right?
>>
>>> maybe you did wath i already found out:
>>>
>>> - worked from a opened Basedoc ?
>> no Base doc open at all, I did this from within a Writer doc.
>>
>>> - you tryed first the code with datasourceName and made the connection
>>> manualy and then changed he code to activeconnection ?
>> Used the same code as you wrote above.
>>
>>> i trye to connect to a MySQL datasource using the Native Connector
>> /me too.
>>
>> Ciao
>> Frank
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]