Test for add dimensions:
a) File olap.vbs
----------------------------------------------------------
Option Explicit
dim dsoServer 'AS DSO.Server
dim dsoDB 'As DSO.MDStore
dim dsoCube 'As DSO.MDStore
Dim intClassType 'as Integer
Dim strClassType 'as String
'Initialize global objects
Set dsoDB = Nothing
Set dsoCube = Nothing
'Create instance of server and connect.
'"LocalHost" will default to the
'local Windows NT Server where the
'OLAP server is installed.
Set dsoServer = CreateObject("DSO.Server")
dsoServer.Connect ("LocalHost")
Dim fso,f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("f:\users\w2000\fgl\debug.txt", 2,1)
'Show the server's information to the user.
f.WriteLine ("Server Properties: Name: " & dsoServer.Name & ", ClassType: " & dsoServer.ClassType)
f.WriteLine ("Description: " & dsoServer.Description & ", machine: " & dsoServer.Machine)
'f.WriteLine ("Server Properties: Name: " & dsoServer.Name & ", ClassType: " & dsoServer.ClassType)
'f.WriteLine ("Description: " & dsoServer.Description & ", machine: " & dsoServer.Machine)
'Declare and allocate local string variables
'for use by the MDStore object.
Dim strDBName 'AS String
Dim strDBDesc 'AS String
strDBName = "Oscar20"
'Add new database to server object collection
'Using the AddNew method from MDStores.
Set dsoDB = dsoServer.MDStores.AddNew(strDBName)
'Assign this description to the MDStore's
'Description property, and call the Update method.
dsoDB.Description = "Oscar DB"
'dsoDB.update
'Inform the user that the database was added to the server.
MsgBox (strDBName & " added to server " & dsoServer.Name)
Dim dsoDS 'AS DSO.DataSource
Dim bResult 'AS Boolean
Dim strConnect 'AS String
Const strProvider = "Provider=MSDASQL.1;"
Const strSecurity = "Persist Security Info=False;"
Const strDataSrc = "Data Source=Oscar20DSN;"
Const strTimeOut = "Connect Timeout=15"
Const strDSName = "Oscar20DSN"
Set dsoDB = dsoServer.MDStores(strDBName)
'Does database already have an attached datasource?
Set dsoDS = dsoDB.DataSources.AddNew(strDSName)
'Build the connection string
strConnect = strProvider & strSecurity & strDataSrc
strConnect = strConnect & strDataSrc & strTimeOut
'Set datasource properties
dsoDS.Name = strDSName
dsoDS.ConnectionString = strConnect
dsoDS.Update
MsgBox ("Datasource added to " & dsoDB.Name)
Dim dsoDim 'AS DSO.Dimension
Dim dsoLev 'AS DSO.Level
Dim strCubeName 'AS String
Dim strMsg 'AS String
Dim bResponse 'AS VbMsgBoxResult
Dim DimCounter 'AS Integer
strMsg = "Create Dimensions and Levels for database " & dsoDB.Name
'Add shared dimensions to Database
'Create Product Dimension and Levels
Set dsoDim = dsoDB.Dimensions.AddNew("Article")
Set dsoDim.DataSource = dsoDS 'Dimension DataSource ####
dsoDim.FromClause = "V_Article_Article" 'Related Table
dsoDim.JoinClause = "" 'Used in snowflake schema
'Product Brand Level
Set dsoLev = dsoDim.Levels.AddNew("Article")
dsoLev.MemberKeyColumn = """V_Article_Article"".""ItemName"""
dsoLev.ColumnSize = 255
dsoLev.ColumnType = 129
dsoLev.EstimatedSize = 1
'Update the dimension
dsoDim.Process
------------------------------------------------------------
b) File test.js
------------------------------------------------------------
//Initialize global objects
var dsoDB = 0;
var dsoCube = 0;
//Create instance of server and connect.
//"LocalHost" will default to the
//local Windows NT Server where the
//OLAP server is installed.
dsoServer = new ActiveXObject("DSO.Server");
dsoServer.Connect ("LocalHost");
//Show the server's information to the user.
WScript.Echo("Name: " + dsoServer.Name);
WScript.Echo("ClassType: " + dsoServer.ClassType);
WScript.Echo("Description: " + dsoServer.Description);
WScript.Echo("machine: " + dsoServer.Machine);
var strDBName = "Oscar20";
var strDBDesc = "oscar olap";
//Add new database to server object collection
//Using the AddNew method from MDStores.
dsoDB = dsoServer.MDStores.AddNew(strDBName);
dsoDB.Description = strDBDesc;
dsoDB.Update;
//Inform the user that the database was added to the server.
WScript.Echo(strDBName + " added to server " + dsoServer.Name);
var strDBName;
var bResult;
//var strConnect = "Provider=MSDASQL.1;Persist Security Info=True;Data Source=Oscar20DSN;";
//strConnect = strConnect + "User ID=sa;Password=;Connect Timeout=15";
var strConnect = "Provider=MSDASQL.1;Persist Security Info=True;Data Source=odbc_w2000osc;";
strConnect = strConnect + "User ID=oscar;Password=adsanker;Connect Timeout=15";
// var strConnect = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=odbc_w2000db;";
// strConnect = strConnect + "Connect Timeout=15";
//var strDSName = "Oscar20DSN";
var strDSName = "odbc_w2000osc";
//Does database already have an attached datasource?
if (dsoDB.DataSources.Count >= 1 )
{
strDBName = dsoDB.Name;
WScript.Echo(strDBName + " database already has a datasource " + strDSName + " attached");
}
//var dsoDS = dsoDB.DataSources.AddNew(strDSName);
dsoDB.DataSources.AddNew(strDSName);
var dsoDS = dsoDB.DataSources(1)
//Set datasource properties
dsoDS.Name = strDSName;
dsoDS.ConnectionString = strConnect;
dsoDS.Update();
WScript.Echo("Datasource added to " + dsoDB.Name);
//var dsoDim;
var dsoLev;
var strCubeName;
var strMsg;
var bResponse;
var DimCounter;
//Add shared dimensions to Database
var dsoDim = dsoDB.Dimensions.AddNew("Article");
dsoDim.DataSource = dsoDB.DataSource(strDSName);
// var dsoDimDS = dsoDim.DataSource;
// dsoDimDS = dsoDS;
//dsoDim.DataSource = dsoDS; //Dimension DataSource
//dsoDim.DataSource = dsoDS.Name; //Dimension DataSource
dsoDim.FromClause = "V_Article_Article"; //Related Table
dsoDim.JoinClause = ""; //Used in snowflake schema
WScript.Echo("Dim add " + dsoDS.Name);
//Add Level
dsoLev = dsoDim.Levels.AddNew("ItemName");
dsoLev.MemberKeyColumn = "\"Article\".\"ItemName\"";
dsoLev.ColumnSize = 255;
dsoLev.ColumnType = 129;
dsoLev.EstimatedSize = 1;
//Update the dimension
dsoDim.Process();
-----------------------------------------------------------
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!