I am so close, I can smell it, but it does not work. Any comments on the steps that I am missing... I think that I need to set default keys and that sort of thing...
The following macro tries to create a databsae document...
Sub NewDB Dim sDBUrl As String 'URL of a New Database document. Dim sTableName As String 'The name of the table to creat. Dim oDoc 'The newly created database document. Dim oTable 'A table in the database. Dim oTables Dim oDescriptor Dim oCols Dim sName As String
sDBUrl = "private:factory/sdatabase" sTableName = "Address" sName = ConvertToURL("C:\OODB\Address01.odb")
'First, create the database document and set the database type oDoc = StarDesktop.loadComponentFromURL(sDBUrl,"_blank",0,Array()) oDoc.Name = sName oDoc.URL = "sdbc:embedded:hsqldb"
REM Logically, I expect that I can call create instance on the database REM document. Unfortunately, this is not correct. oTables = oDoc.getTables() If (oTables.getCount() < 1) Then oTable = oTables.createInstance("com.sun.star.sdbcx.Table") oCols = oTable.getColumns()
oDescriptor = oCols.createDataDescriptor() oDescriptor.IsNullable = 0 oDescriptor.Precision = 50 oDescriptor.Name = "LastName" oDescriptor.Type = 12 oDescriptor.TypeName = "VARCHAR" oCols.appendByDescriptor(oDescriptor)
REM I do not have to create a new descriptor, I can use the existing one.
REM This makes things easier if I add similar columns.
oDescriptor.Name = "FirstName"
oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "Address" oDescriptor.IsNullable = 1 oDescriptor.Precision = 200 oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "City" oDescriptor.Precision = 50 oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "StateOrProvince" oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "PostalCode" oDescriptor.Precision = 20 oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "PhoneNumber" oDescriptor.Precision = 30 oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "FaxNumber" oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "MobileNumber" oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "DateUpdated" oDescriptor.Precision = 0 oDescriptor.Type = 91 oDescriptor.TypeName = "DATE" oCols.appendByDescriptor(oDescriptor)
oDescriptor.Name = "CountryOrRegion" oDescriptor.Precision = 50 oDescriptor.Type = 12 oDescriptor.TypeName = "VARCHAR" oCols.appendByDescriptor(oDescriptor)
oTables.insertByName(sTableName, oTable) End If oDoc.store() End Sub
-- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.sxw My Macro Book: http://www.hentzenwerke.com/catalog/oome.htm Free Info: http://www.pitonyak.org/oo.php
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]