OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Change View State of tables in a Database?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
PBiela
Power User
Power User


Joined: 10 Feb 2004
Posts: 56
Location: Frankfurt/Main Germany

PostPosted: Thu Mar 25, 2004 6:02 am    Post subject: Change View State of tables in a Database? Reply with quote

Hello again,

one tricky problem again.

I'm saving dbf table files into a database directory. My Database is getting access to them using the manual way and I'm able to change them to visible for the Database using the admin tools in OpenOffice.

Using Macros I haven't found a way to do that yet.

Code:
 
Sub Main

   DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
   DataSource = DatabaseContext.getByName("Biblio")
   
        Connection = DataSource.GetConnection("","")
       
        For i = 0 to Ubound(DataSource.TableFilter())
              TablesStr =  TablesStr & DataSource.TableFilter(i) & Chr(013)
        Next i
        MsgBox TablesStr
   
End Sub


This snipplet displays all visible tables, but not those which are invisble. Rolling Eyes they are invisible ha ha ...

Anyone knows how to change the state visible for a table using macro?

I think that it must be located somewhere within the sdbcx module, but I simply
can't find it.

Peter Biela
_________________
Question Who is John Galt? - Ayn Rand Question
Back to top
View user's profile Send private message
PBiela
Power User
Power User


Joined: 10 Feb 2004
Posts: 56
Location: Frankfurt/Main Germany

PostPosted: Thu Mar 25, 2004 7:13 am    Post subject: Reply with quote

hmmm a very dirty way might be this:

Code:



Sub Main

 installDatasource ("test" , "file:/misc/home/TestDB/DatBase/Test")

End Sub

Sub installDatasource ( sDataSourceName as String , sPath as String )
   ' Variablen deklarieren
   Dim oDataSource as Object
   Dim oDatasourceContext as Object
   Dim oSimpleFileAccess as Object
   Dim sPath as String

   ' Datenbank-Kontext holen
   oDatasourceContext = createUnoService( "com.sun.star.sdb.DatabaseContext" )

'remove Registration
    oDatasourceContext.revokeObject(sDataSourceName)


   If ( oDatasourceContext.hasByName ( sDataSourceName ) ) Then
      MsgBox "Datenquelle schon vorhanden"
      Exit Sub
   End If

   sPath = ConvertToUrl( sPath )
   oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" )
   if ( Not( oSimpleFileAccess.exists(sPath) And oSimpleFileAccess.isFolder(sPath) ) ) Then
      MsgBox "Ungültiges Verzeichnis: " & sPath & chr(13)
      Exit Sub

   End If

'reset Registration
   sDataSourceScheme = "sdbc:dbase:"
   oDataSource = oDatasourceContext.createInstance()
   oDataSource.URL = sDataSourceScheme & sPath
   oDatasourceContext.registerObject( sDatasourceName , oDataSource )
End Sub




The code was found mainly here:

http://www.bcwin.ch/ooo/tools/oooDocManagement.html#addDataSource

Using this code I first remove the database completly from registration and then add it new.
Thus all dbf files in the directory are visible.


But this is just a very bad way to do it, cause you can't specify a single table to be visible or not to the database. So any help is appreciated.

Peter Biela
_________________
Question Who is John Galt? - Ayn Rand Question
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group