Set Datasource of an Dimension - VB-Script/JScript

Set Datasource of an Dimension - VB-Script/JScript

Post by frank iverse » Tue, 12 Jun 2001 17:41:01



Hallo,

I want to create an OLAP-Database with an script.
Connection with the DB,
and so on and so on - this is OK.

But I have an problem, setting the datasource of an
new dimension.

The Problem.
VB-Script:
   Set dsoDS = dsoDB.DataSources.AddNew ("...")
   ...
   Set dsoDim = dsoDB.Dimension.AddNew("...")
   Set dsoDim.DataSource = dsoDS
-->> this is OK

JScript:
   dsoDS = dsoDB.DataSources.AddNew("...")
   ...
   dsoDim = dsoDB.Dimensions.AddNew("...")
   dsoDim.DataSource = dsoDS
-->> at the last line, I get an error:
----- Error: Object doesn't support this action

I need it in JScript.

So long Frank Iversen

 
 
 

Set Datasource of an Dimension - VB-Script/JScript

Post by John Des » Fri, 15 Jun 2001 03:45:07


Hello Frank:

You may want to try something like the following:
dsoDS = dsoDB.DataSources.AddNew("My Data Source")
..
dsoDim = dsoDB.Dimensions.AddNew("MyDimension")
dsoDim.DataSource=dsoDB.DataSources("My Data Source")

If that fails, you may want to update the jscript engine to 5.5, if you
haven't already done that.
You could also try casting the dsoDS.

John Desch, MCDBA, MCSD

 
 
 

Set Datasource of an Dimension - VB-Script/JScript

Post by frank iverse » Sat, 16 Jun 2001 20:24:40


Hello,

it don't work.
I think, the problem is:
- there are two Dimension-property-put functions;
  one works with a reference and the other with
  an object-copy.
- in VBScript, it is possible to select between them,
  but not in JScript, or ?
- the situation is, the machine find the function with
  the object-copy and so setting is not possible.

So long
Frank Iversen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Set Datasource of an Dimension - VB-Script/JScript

Post by John Des » Thu, 21 Jun 2001 06:31:59


Frank:

I know that there have been a couple of issues with late binding causing a
similar error. In this case, however, I tend to doubt that is what's
occurring, since VBScript and JScript are both late binding.

Could you post the entire jscript so that we can test it further?

Regards,

John Desch, MCDBA, MCSD

 
 
 

Set Datasource of an Dimension - VB-Script/JScript

Post by frank iverse » Thu, 21 Jun 2001 16:52:52


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!

  crazy.html
5K Download
 
 
 

1. New Dimension, set datasource with VBScript and JScript

Hallo,

I want to create an OLAP-Database with an script.
Connection with the DB,
and so on and so on - this is OK.

But I have an problem, setting the datasource of an
new dimension.

The Problem.
VB-Script:
   Set dsoDS = dsoDB.DataSources.AddNew ("...")
   ...
   Set dsoDim = dsoDB.Dimension.AddNew("...")
   Set dsoDim.DataSource = dsoDS
-->> this is OK

JScript:
   dsoDS = dsoDB.DataSources.AddNew("...")
   ...
   dsoDim = dsoDB.Dimensions.AddNew("...")
   dsoDim.DataSource = dsoDS
-->> at the last line, I get an error:
----- Error: Object doesn't support this action

I need it in JScript.

So long Frank Iversen

2. SQL Repository Security

3. Set 'DataSource' of an dimension

4. VB% and MSAccess

5. Set Datasource of an Dimension

6. transaction log backup

7. Ann: Script to set image pixel dimensions

8. Clarification of the extreme newbie questions

9. VBScript file connects, but JScript doesn't..

10. dimensions datasources

11. Changing dimension datasource name in MSAS

12. Dimensions in differents databases / datasources