BusinessObjects Board

Add Table using Universe Designer SDK

That problem will also happen if the table you’re trying to create has the same name as a table you’ve already created. If so, you can just add a number to the end. If that isn’t the problem, try adding Double quotes around it. In VB.NET I use:

Private Function CreateTable(ByVal Universe As Designer.Universe, ByVal TableName As String, ByRef X As Integer, ByRef Y As Integer, ByVal Derived As Boolean, Optional ByVal TableDesc As String = "") As Designer.Table
            Dim NewTable As Designer.Table
            Try
                NewTable = Universe.Tables.Add(TableName.ToUpper))
                TableDesc = """" & TableDesc.Trim("""") & """")
                NewTable = Universe.Tables.Item(NewTable.Name).CreateAlias(TableDesc))
            Catch ex As Exception
                Dim Temp As Integer
                Temp = 2
                While True
                    Try
                        NewTable = Universe.Tables.Item(TableName).CreateAlias("""" & TableDesc & "_" & Temp & """"))
                        Exit While
                    Catch ex2 As Exception
                        Temp += 1
                    End Try
                End While
            End Try
            Return NewTable
        End Using
    End Function

That would try to create the table and an alias for it, and if unsuccessful, would try to create just an alias with a number after it. Hopefully this helps you a little.


Sivvy (BOB member since 2009-02-19)

Hi all,
Thanks for your help.
I’m using VB.NET too.

When i try to add a new table in an empty universe
Universe.Tables.Add(table_name)
I actually do have the new table created in the universe but the table is blank: no column in it.
Why do i get an empty table? Is this Tables.add supposed to brings up all the columns with it or am i supposed to add each column?

Is there a way to add a table (by its name) from the database (that would brings up all its columns and everything) ?
Just like when you insert a table in the Designer basically.

If anyone has a code sample to show an exemple, that would help a lot :wink:


ceka (BOB member since 2009-02-23)

I had the same problem… All I did was loop all my tables in with the correct names, and then used

ObjUniverse.RefreshStructure()

AFTER they were all in there. I emphasize AFTER because the refresh is SLOW. Don’t put the Refresh in the loop.

If you want to automate the actual universe pane afterwards, just use

ObjUniverse.Tables.Item("Table'sExactName").CreateClass("Class'sNewName")

Sivvy (BOB member since 2009-02-19)

Thanks Sivvy

The ObjUniverse.RefreshStructure() worked fine!!
Thx :wink:


ceka (BOB member since 2009-02-23)

Can you please let me how to add Joins between tables & Class Object in Univers using Designer SDK.


2732829 (BOB member since 2009-03-06)

Check that topic

Good luck


ceka (BOB member since 2009-02-23)

Thanks, but I already go through this link and there is no code to ADD Object in Universe using Desinger Universe SDK.

Please help me if you have idea about this.


2732829 (BOB member since 2009-03-06)

Basically that would go like

Dim Cls As Designer.Class
Dim Obj As Designer.Object

Set Cls = Univ.Classes.Add("Classe Name")
'or Set Cls = Univ.Classes.FindClass("Classe Name") if class already exists
Cls.Description = "blabla"
etc ...

Set Obj = Cls.Objects.Add("ObjectName")
Obj.Type = dsNumericVariable
Obj.Description = "desc"
Obj.Select = "TABLE.COL"

ceka (BOB member since 2009-02-23)

Something similar that actually extracts the objects from the table columns:

Dim Cls As Designer.Class
Dim myTableName As String = "ExampleTable"

Univ.Tables.Add(myTableName)
Univ.RefreshStructure()

Set Cls = Univ.Tables.Item(myTableName).Classes.Add("Class Name")

If “myTableName” actually exists in the database, this would add the table, populate the columns, then create a class with all the columns in it as objects.


Sivvy (BOB member since 2009-02-19)

Hi,

Can you please let me how can I create “Filter” in Universe through Designer SDK.


2732829 (BOB member since 2009-03-06)

I want to insert Tables Joins Using Desinger Universe SDK. And If I have Alias table the how can we do using Desinger Universe SDK?


2732829 (BOB member since 2009-03-06)

Call Univ.Joins.Add("syntax of join") 'including alias if you like

Also, I removed your duplicate post from the BOB’s Downloads topic.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hi Dwayne,

Thanks for your reply. I already used “Univ.Joins.Add(Join Condition)” text for this is not working for Alias tables And second this statement show correct join Expression but its selected all field for second table.

Please let me if you have solution for this issue.


2732829 (BOB member since 2009-03-06)

I don’t know what to say, it works for me … including fields from aliased tables.

Here is something to try. Create the join manually. Copy the join syntax into Notepad or something, and close the universe without saving it. Now use that EXACT same join syntax in your VBA code. It HAS to work.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Have you made sure to include double quotes on re-named tables? One of the first problems I ran into was the double quotes.


Sivvy (BOB member since 2009-02-19)

Hi,

How can I create new universe with new connection through Designer Universe SDK.


2732829 (BOB member since 2009-03-06)

Take a look at the Designer SDK documentation, because both the .Universes and .Connections collections have a .Add method. The bigger question is why you would want to do this? Creating universes and connections are a one-time activity, so I’m not sure what value automation has … at least from a best practice approach.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hi Dwayne,

Yes you are rite that this is only one time job but I’m creating universe through SDK code on any database. Now only this are left I’m able to Create new universe and also able to save with any name but when I tried to change universe default name then I’m getting error :

For example :
Dim Univ as Designer.Universe

Univ = DesingerApp.Universes.Add()
Univ.Name=“Test”

then I’m getting Error “unable to write read only property”. DO you have any idea how can I change Universe name.

Thanks for your help.


2732829 (BOB member since 2009-03-06)

The documentation says .Name is a read/write property, but we all know the documentation can be wrong :yesnod: . This property is the filename, so it makes sense that it can’t be changed. A new universe doesn’t really have a name, so use the .SaveAs method to save the file with the name of your choice.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hi Dwayne,

Thanks for your Input.

I have another Issue like I tried to create New Connection and I’m writting code :

UnivConn = DesingerApp.Connections.Add(“DOT_1”, Designer.DsConnectionType.dsSecured, “OLE DB”, “MS SQL Server 2005”, “SYNGDCD1601”, “sa”, “syntel123$”, “HCA”, “”)

But I’m getting error “No rights, cannot add connection”. Please help me why I’m getting this issue or I’m doing something wrong.


2732829 (BOB member since 2009-03-06)