dbTalk Databases Forums  

Cannot create cube using DSO or using ADOMD

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Cannot create cube using DSO or using ADOMD in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Justin
 
Posts: n/a

Default Cannot create cube using DSO or using ADOMD - 07-15-2005 , 10:26 AM






What am I doing wrong?

When I try to create a cube using DSO, I get an error saying, 'Cannot
update. Database or object is read-only.'. The code is:

dsoServer.Connect( GssCommonAPI.GetConfigKey("OLAPServerName") );

// Ensure that the database exists
if( dsoServer.MDStores.Find( databaseName ) == false )
errMsg = string.Format("Database {0} is not found.",
databaseName);
else
{
// get the database
dsoDatabase = (DSO.MDStore)dsoServer.MDStores.Item(databaseName) ;
DSO.Database localDSODatabase =
(DSO.Database)dsoServer.MDStores.Item(databaseName );

// Check for existing data sources, dimensions, and cubes.

if( dsoDatabase.DataSources.Count == 0 )
errMsg = string.Format("Database {0} has no data sources.",
databaseName);
else if( dsoDatabase.Dimensions.Count == 0 )
errMsg = string.Format("Database {0} has no dimensions",
databaseName);
else if( dsoDatabase.MDStores.Find(cubeName) )
errMsg = string.Format("cube {0} already exists in database {1}",
cubeName, databaseName);
else
{

bool IsReadWrite = dsoDatabase.IsReadWrite;

// add the new cube
localDSODatabase.Cubes.AddNew(cubeName,
DSO.SubClassTypes.sbclsRegular);
DSO.Cube newCube =
(DSO.Cube)dsoDatabase.MDStores.AddNew(cubeName,
DSO.SubClassTypes.sbclsRegular);
dsoCube = (DSO.MDStore)dsoDatabase.MDStores.AddNew(cubeName,
DSO.SubClassTypes.sbclsRegular);

dsoCube.DataSources.AddNew(
dsoDatabase.DataSources.Item(1).ToString(),
DSO.SubClassTypes.sbclsRegular );

dsoCube.EstimatedRows = 100000;

// Add Dimensions
dsoCube.Dimensions.AddNew("Products",
DSO.SubClassTypes.sbclsRegular);

// Add two measures
dsoCube.Measures.AddNew("Store Cost",
DSO.SubClassTypes.sbclsRegular);

dsoCube.Update();
result = true;

}
}

--------------------------------------------------------------
And when I try using ADOMD, I always get a token not valid error:

protected string createCubeString = @"CREATE CUBE SalesLocal
(
MEASURE [SalesCustomer].[Actual],
MEASURE [SalesCustomer].[Budget],
MEASURE [SalesCustomer].[No Of Customers],
DIMENSION [SalesCustomer].[Product],
DIMENSION [SalesCustomer].[Warehouse]
)
";

Connection con = new ADODB.ConnectionClass();
ADOMD.Catalog ct = new Catalog();
ADOMD.Cellset cellSet = new CellsetClass();

try
{
con.Open(constr,"sa","",0);

ct.ActiveConnection = con;
int totalcubes = 0;
totalcubes = ct.CubeDefs.Count;

//cellSet.ActiveConnection = con;
//cellSet.Source = createCubeString;

cellSet.Open(createCubeString, con);
body.Text = totalcubes.ToString();

}
catch(Exception e)
{
body.Text = e.Message;
}
finally
{
con.Close();
}


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.