Monday, March 12, 2012

Passing a schema to a cube via AMO

I'm having a problem passing the Schema name to the cube when building it using AMO.
Oh, i'm using SQL Server 2k5.

When i build the cube through Dev Studio, it will process dimensions as expected. So, when pulling data, i can look at the SQL and see (for example):

"Select blah from Schema.TableName"

Which is what i want. However, when i build the cube using AMO i can not process the dimension, and it's failing because the SQL reads:

"Select blah from TableName"

A quick fix for me is to remove the Schema from my tables.. so, dbo.TableName works fine. But that's not exactly what i want. Or, i can create stored procs that pull the data from any table/schema, but that's not what i want either..

So, i guess i'm asking if there's a way to pass a schema to a dataset and have it read by the cube.

Any help would be appreciated..
Thanks,

Chris.

The following snippet is from the AMOAdventureWorks sample that is part of the SQL Server 2005 samples. It comes from the part of the program where they are building the DSV. Note that there are two points where the dbo schema is hard coded. I am hoping that by passing in your own schema name will resolve your issue.

staticvoid AddTable(DataSourceView dsv, OleDbConnection connection, String tableName)

{

OleDbDataAdapter adapter = newOleDbDataAdapter(

"SELECT * FROM [dbo].[" + tableName + "] WHERE 1=0",

connection);

DataTable[] dataTables = adapter.FillSchema(dsv.Schema,

SchemaType.Mapped, tableName);

DataTable dataTable = dataTables[0];

dataTable.ExtendedProperties.Add("TableType", "Table");

dataTable.ExtendedProperties.Add("DbSchemaName", "dbo");

dataTable.ExtendedProperties.Add("DbTableName", tableName);

dataTable.ExtendedProperties.Add("FriendlyName", tableName);

}

|||excellent, thanks so much!

dataTable.ExtendedProperties.Add("DbSchemaName", "dbo"); worked exactly as i needed it to, by replacing it with my own schema name.

No comments:

Post a Comment