Hi Matthias,

> I'm not really interested in the DSB. What I really want to do is to
> connect an open document that has mail merge fields to a different CSV
> file. I played around with DocumentSettings.CurrentDatabaseCommand and
> changing this seemed to be what I want. I thought my problem was just
> that the value I wanted to set here was the name of a new table that
> the running OO instance hadn't picked up. But now it seems that this
> won't work, even if I get OO to update the table list.
> 
> I think I need to implement the "Exchange Database" function (see
> http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=13787). If I
> manage to do this, then I guess I can just register a new database for
> my CSV directory.

Shouldn't this be CurrentDatabaseDataSource / CurrentDatabaseCommand /
CurrentDatabaseCommandType?
(http://api.openoffice.org/docs/common/ref/com/sun/star/document/Settings.html#CurrentDatabaseDataSource)

A triple of DataSource/Command/CommandType is usually (in different
contexts) used to unambiguously denote a "result set" (which can be from
a table, query, or only SQL statement, of a specific database).

I would *expect* that those three are what "Exchange Database" modifies.


Note that a component using such a triple to describe a result set
usually has a sdb.Connection associated with it, and what you really
want to do is to refresh the tables of the Connection associated with
the mail merge document's CurrentDatabaseXXX.
Unfortunately, it seems the document does not expose this connection -
if it would, you could just do something like
  DocumentSettings.CurrentDatabaseConnection.getTables().refresh()

Alas, there is no CurrentDatabaseConnection (side note: feel free to
submit a request for enhancement issue, requiring such a property. I
think your use case is an excellent example to justify it).


So, as a workaorund, you could do what you described: create a new data
source pointing to the same CSV files, and pass it to the document.
For creating such a data source, use something like (I have to ensure
that there is a code snippet for this somewhere, given how often I typed
this :)
  oDBC = createUnoService( "com.sun.star.sdb.DatabaseContext" )
  oDS = oDBC.createIntance()
  oDS.<some_properties> = <some_values>
    ' here I suggest you use oDBC.getByName( <existent_name> )
    ' and examine this object, e.g. via XRay, to see what properties
    ' are needed. You only need to do this once, then you can hard-code
    ' them here
  oDS.storeTo( <temp_file_url> )

  DocumentSettings.CurrentDatabaseDataSource = <temp_file_url>

Along those lines, you should be able to base your mail merge on the
very recent table list.

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer         [EMAIL PROTECTED] -
- Sun Microsystems                      http://www.sun.com/staroffice -
- OpenOffice.org Database                   http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to