home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / MSOLAP / samples / Samples.exe / VbDSOExample / AdvancedSampleCode.bas next >
Encoding:
BASIC Source File  |  1998-10-30  |  22.5 KB  |  636 lines

  1. Attribute VB_Name = "AdvancedSampleCode"
  2. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  3. '
  4. ' AdvancedSampleCode.bas - Contains the advanced functions for maintaining a cube.
  5. '
  6. ' (C)Copyright 1998, Microsoft Corporation. All rights reserved.
  7. '
  8. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  9.  
  10. Option Explicit
  11. Option Compare Text
  12.  
  13.  
  14. '
  15. '   CreateCalculatedMember - create a calculated measure called Average Sale
  16. '                            Average Sale = Store Sales / Sales Count
  17. '
  18. Public Sub CreateCalculatedMember()
  19.     ' lock the cube for writing
  20.     ' so that no other application can modify it
  21.     On Error GoTo Err_Lock
  22.     m_dsoCube.LockObject olaplockWrite, _
  23.                          "DSOSample is adding calculated member to the cube"
  24.         
  25.     ' create the new calculated member
  26.     On Error GoTo Err_Create
  27.     Dim dsoCalculatedMember As DSO.Command
  28.     Set dsoCalculatedMember = m_dsoCube.Commands.AddNew("Average Sale")
  29.     
  30.     ' set the command type
  31.     dsoCalculatedMember.CommandType = cmdCreateMember
  32.     
  33.     ' set the MDX statement that defines the calculated member
  34.     dsoCalculatedMember.Statement = _
  35.             "CREATE MEMBER Sales.Measures.[Average Sale] AS " & _
  36.                 "'[Measures].[Store Sales]/[Measures].[Sales Count]', " & _
  37.                 "FORMAT_STRING = 'Currency'"
  38.     
  39.     ' save the cube definition in the metadata repository
  40.     ' the calculated member will be saved as a part of the cube
  41.     On Error GoTo Err_Update
  42.     m_dsoCube.Update
  43.         
  44.     ' unlock the cube
  45.     m_dsoCube.UnlockObject
  46.         
  47. Exit Sub
  48.  
  49. Err_Lock:
  50.     ' Failed to lock the cube
  51.     ' Possible reasons:
  52.     '   - the cube is already locked by another application
  53.     '   - the machine on which OLAP server is running is not reachable
  54.  
  55. Err_Create:
  56.     ' Failed to create the calculated member.
  57.     ' Possible reasons:
  58.     '   - the metadata repository is unreachable
  59.     
  60. Err_Update:
  61.     ' Failed to persist the cube definition in the metadata repository
  62.     ' Possible reasons:
  63.     '   - the metadata repository is unreachable
  64.     '       you can see where the metadata repository resides by looking
  65.     '       up the following registry entry:
  66.     '       HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
  67.     '           Repository Connection String
  68.     
  69.     ' unlock the cube
  70.     m_dsoCube.UnlockObject
  71.     
  72.     MsgBox "Create calculated member failed" & vbCrLf & Err.Description
  73.     
  74. End Sub
  75.  
  76.  
  77. '
  78. '   CreateVirtualDimension - create a virtual dimension based on
  79. '                            Store dimension
  80. '
  81. Public Sub CreateVirtualDimension()
  82.     ' get the reference to the Store dimension
  83.     Dim dsoStoreDim As DSO.Dimension
  84.     Set dsoStoreDim = m_dsoDatabase.Dimensions("Store")
  85.     
  86.     ' lock the Store dimension for reading
  87.     ' so that no other application can modify it
  88.     On Error GoTo Err_Lock
  89.     dsoStoreDim.LockObject olaplockRead, _
  90.                            "DSOSample is creating a virtual dimension based on Store"
  91.         
  92.     ' create the new virtual dimension in the
  93.     ' database's Dimensions collection
  94.     On Error GoTo Err_Create
  95.     Dim dsoVirtualDimension As DSO.Dimension
  96.     Set dsoVirtualDimension = m_dsoDatabase.Dimensions.AddNew("Store Type")
  97.     
  98.     ' lock the dimension so that no app can alter it
  99.     On Error GoTo Err_Lock
  100.     dsoVirtualDimension.LockObject olaplockWrite, _
  101.                                    "DSOSample is setting properties of the virtual dimension"
  102.     
  103.     '
  104.     ' create dimension levels
  105.     '
  106.     Dim dsoLevel As DSO.Level
  107.     
  108.     '
  109.     ' create the All level
  110.     '   the All level is the top-most level in the dimension hierarcy
  111.     On Error GoTo Err_Create
  112.     Set dsoLevel = dsoVirtualDimension.Levels.AddNew("All")
  113.     
  114.     ' set the level type
  115.     dsoLevel.LevelType = levAll
  116.     
  117.     ' the All level has only one member
  118.     ' set the MemberKeyColumn of the All level to a constant
  119.     ' this constant is at the same time the name of that single member
  120.     dsoLevel.MemberKeyColumn = "All Store Types"
  121.     
  122.     '
  123.     ' create the virtual level
  124.     '   the virtual level is based on a member property from the
  125.     '   source dimension
  126.     On Error GoTo Err_Create
  127.     Set dsoLevel = dsoVirtualDimension.Levels.AddNew("Store Type", sbclsVirtual)
  128.         
  129.     ' members of the virtual level come from the source dimension
  130.     ' MemberKeyColumn of a virtual level has the following format:
  131.     '   [<dim name>].[<level name>].[<member property name>]
  132.     dsoLevel.MemberKeyColumn = "[Store].[Store Name].[Store Type]"
  133.     
  134.     ' save the virtual dimension definition in the metadata repository
  135.     On Error GoTo Err_Update
  136.     dsoVirtualDimension.Update
  137.         
  138.     ' unlock the dimensions
  139.     dsoStoreDim.UnlockObject
  140.     dsoVirtualDimension.UnlockObject
  141.     
  142.     
  143.     '
  144.     '   add the virtual dimension to the cube
  145.     '
  146.     
  147.     ' lock the cube for writing
  148.     On Error GoTo Err_LockCube
  149.     m_dsoCube.LockObject olaplockWrite, _
  150.                          "DSO Sample is adding a dimension to the cube"
  151.                          
  152.     m_dsoCube.Dimensions.AddNew "Store Type"
  153.     
  154.     ' save the cube definition in the metadata repository
  155.     On Error GoTo Err_UpdateCube
  156.     m_dsoCube.Update
  157.     
  158.     ' unlock cube
  159.     m_dsoCube.UnlockObject
  160.     
  161. Exit Sub
  162.  
  163. Err_Lock:
  164.     ' Failed to lock the dimension
  165.     ' Possible reasons:
  166.     '   - the object is already locked by another application
  167.     '   - the machine on which OLAP server is running is not reachable
  168.  
  169. Err_Create:
  170.     ' Failed to create the dimension.
  171.     ' Possible reasons:
  172.     '   - the metadata repository is unreachable
  173.     
  174. Err_Update:
  175.     ' Failed to persist the cube definition in the metadata repository
  176.     ' Possible reasons:
  177.     '   - the metadata repository is unreachable
  178.     '       you can see where the metadata repository resides by looking
  179.     '       up the following registry entry:
  180.     '       HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
  181.     '           Repository Connection String
  182.     
  183.     ' unlock the dimensions
  184.     dsoStoreDim.UnlockObject
  185.     dsoVirtualDimension.UnlockObject
  186.     
  187. Err_UpdateCube:
  188.     ' unlock cube
  189.     m_dsoCube.UnlockObject
  190.     
  191. Err_LockCube:
  192.     ' Failed to lock the cube
  193.     
  194.     MsgBox "Create virtual dimension failed" & vbCrLf & Err.Description
  195.     
  196. End Sub
  197.  
  198.  
  199. '
  200. '   CreateVirtualCube - create a virtual cube based on the Sales cube
  201. '                       the virtual cube will be a subset of the Sales cube,
  202. '                       i.e. it will only have one measure Store Profit
  203. '
  204. Public Sub CreateVirtualCube()
  205.     
  206.     ' lock the Sales cube for reading
  207.     ' so that no other application can modify it
  208.     On Error GoTo Err_Lock
  209.     m_dsoCube.LockObject olaplockRead, _
  210.                          "DSOSample is creating a virtual cube based on Sales"
  211.         
  212.     ' create the new virtual cube in the
  213.     ' database's MDStores collection
  214.     On Error GoTo Err_Create
  215.     Dim dsoVirtualCube As DSO.MDStore
  216.     Set dsoVirtualCube = m_dsoDatabase.MDStores.AddNew("Virtual Sales", sbclsVirtual)
  217.     
  218.     ' lock the virtual cube so that no app can alter it
  219.     On Error GoTo Err_Lock
  220.     dsoVirtualCube.LockObject olaplockWrite, _
  221.                               "DSOSample is setting properties of the virtual cube"
  222.     
  223.     '
  224.     ' add the measure to the virtual cube
  225.     '
  226.     Dim dsoMeasure As DSO.Measure
  227.     Set dsoMeasure = dsoVirtualCube.Measures.AddNew("Store Profit")
  228.     
  229.     ' map this measure to the Sales cube Store Profit
  230.     ' NOTE: the format of virtual cube measure is:
  231.     '       [<cube name>].[<measure name>]
  232.     dsoMeasure.SourceColumn = "[Sales].[Store Profit]"
  233.     
  234.     '
  235.     ' add the dimensions to the virtual cube
  236.     ' NOTE: with exception of virtual dimensions, all of the
  237.     '       dimensions must be included in the cubes on which virtual
  238.     '       cube measures are based
  239.     dsoVirtualCube.Dimensions.AddNew "Product"
  240.     dsoVirtualCube.Dimensions.AddNew "Time"
  241.     dsoVirtualCube.Dimensions.AddNew "Store"
  242.     dsoVirtualCube.Dimensions.AddNew "Store Type"
  243.     
  244.     ' save the virtual cube definition in the metadata repository
  245.     On Error GoTo Err_Update
  246.     dsoVirtualCube.Update
  247.         
  248.     ' unlock the cubes
  249.     m_dsoCube.UnlockObject
  250.     dsoVirtualCube.UnlockObject
  251.         
  252. Exit Sub
  253.  
  254. Err_Lock:
  255.     ' Failed to lock the cube
  256.     ' Possible reasons:
  257.     '   - the object is already locked by another application
  258.     '   - the machine on which OLAP server is running is not reachable
  259.  
  260. Err_Create:
  261.     ' Failed to create the virtual cube.
  262.     ' Possible reasons:
  263.     '   - the metadata repository is unreachable
  264.     
  265. Err_Update:
  266.     ' Failed to persist the cube definition in the metadata repository
  267.     ' Possible reasons:
  268.     '   - the metadata repository is unreachable
  269.     '       you can see where the metadata repository resides by looking
  270.     '       up the following registry entry:
  271.     '       HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
  272.     '           Repository Connection String
  273.     
  274.     ' unlock the cubes
  275.     m_dsoCube.UnlockObject
  276.     dsoVirtualCube.UnlockObject
  277.     
  278.     MsgBox "Create virtual cube failed" & vbCrLf & Err.Description
  279.     
  280. End Sub
  281.  
  282.  
  283. '
  284. '   CreatePrivateDimension - create the private Customer dimension
  285. '
  286. '   NOTE: private dimensions can be used in only one cube
  287. '
  288. Public Sub CreatePrivateDimension()
  289.     ' create the Customer dimension in the database's
  290.     ' Dimensions collection
  291.     ' NOTE: private dimension name contains the name of the cube
  292.     '       and the name of the dimension, separated by '^'
  293.     On Error GoTo Err_Create
  294.     Dim dsoDimension As DSO.Dimension
  295.     Set dsoDimension = m_dsoDatabase.Dimensions.AddNew("Sales^Customer")
  296.  
  297.     ' lock the dimension so that no app can alter it
  298.     On Error GoTo Err_Lock
  299.     dsoDimension.LockObject olaplockWrite, _
  300.                             "DSOSample is setting properties of the private dimension"
  301.     
  302.     ' set the dimension's datasource
  303.     Set dsoDimension.DataSource = m_dsoDatabase.DataSources("Foodmart Sample Database")
  304.     
  305.     ' get the quoting characters from the datasource
  306.     Dim sLQuote As String, sRQuote As String
  307.     sLQuote = dsoDimension.DataSource.OpenQuoteChar
  308.     sRQuote = dsoDimension.DataSource.CloseQuoteChar
  309.     
  310.     ' set the dimension type
  311.     dsoDimension.DimensionType = dimRegular
  312.     
  313.     ' set the comma separated list of the dimension tables
  314.     ' NOTE: the tables must be quoted
  315.     ' the Customer dimension uses only the "customer" table
  316.     dsoDimension.FromClause = sLQuote & "customer" & sRQuote
  317.                                   
  318.     '
  319.     ' create dimension levels
  320.     '
  321.     Dim dsoLevel As DSO.Level
  322.     
  323.     '
  324.     ' create the All level
  325.     '   the All level is the top-most level in the dimension hierarcy
  326.     On Error GoTo Err_Create
  327.     Set dsoLevel = dsoDimension.Levels.AddNew("All")
  328.     
  329.     ' set the level type
  330.     dsoLevel.LevelType = levAll
  331.     
  332.     ' the All level has only one member
  333.     ' set the MemberKeyColumn of the All level to a constant
  334.     ' this constant is at the same time the name of that single member
  335.     dsoLevel.MemberKeyColumn = "All Customers"
  336.     
  337.     '
  338.     ' create the Customer Country level
  339.     '   the Customer Country level contains all of the countries
  340.     On Error GoTo Err_Create
  341.     Set dsoLevel = dsoDimension.Levels.AddNew("Customer Country")
  342.     
  343.     ' set the level type
  344.     dsoLevel.LevelType = levRegular
  345.     
  346.     ' define which column contains the level member keys
  347.     ' sLQuote and sRQuote are obtained from dsoDimension.Datasource
  348.     ' NOTE: the tables and columns must be quoted using the quoting
  349.     '       characters obtained from the dimension's datasource
  350.     dsoLevel.MemberKeyColumn = sLQuote & "customer" & sRQuote & "." & _
  351.                                sLQuote & "country" & sRQuote
  352.  
  353.     ' tell DSO how many members this level has
  354.     ' this information will be used during the design of aggregations
  355.     '   when determining the optimal set of aggregations
  356.     ' there are 3 countries in the "customer" table: Mexico, Canada, and USA
  357.     dsoLevel.EstimatedSize = 3
  358.     
  359.     ' this level contains unique members
  360.     dsoLevel.IsUnique = True
  361.     
  362.     ' DSO needs to know what is the type and maximum size of the members keys
  363.     ' NOTE: the ColumnSize property needs to be set only for
  364.     '       levels that have string members
  365.     dsoLevel.ColumnType = adChar
  366.     dsoLevel.ColumnSize = 6         ' the longest members ("Mexico", "Canada")
  367.                                     ' can fit in 6 characters
  368.     
  369.     ' specify how should the level members be ordered
  370.     ' we want the countries ordered by Name
  371.     dsoLevel.Ordering = orderName
  372.     
  373.     '
  374.     ' create the Customer State level
  375.     '   the Customer State level contains all of the states
  376.     On Error GoTo Err_Create
  377.     Set dsoLevel = dsoDimension.Levels.AddNew("Customer State")
  378.     
  379.     ' set the level type
  380.     dsoLevel.LevelType = levRegular
  381.     
  382.     ' "customer_state" column contains members for this level
  383.     dsoLevel.MemberKeyColumn = sLQuote & "customer" & sRQuote & "." & _
  384.                                sLQuote & "state_province" & sRQuote
  385.  
  386.     ' there are 13 distinct states in the "customer" table
  387.     dsoLevel.EstimatedSize = 13
  388.     
  389.     ' this level contains unique members,
  390.     ' i.e. no state appears in more than one country
  391.     dsoLevel.IsUnique = True
  392.     
  393.     ' DSO needs to know what is the type and maximum size of the members keys
  394.     dsoLevel.ColumnType = adChar
  395.     dsoLevel.ColumnSize = 9             ' the longest member ("Zacatecas")
  396.                                         ' can fit in 9 characters
  397.     
  398.     ' we want the states ordered by Name
  399.     dsoLevel.Ordering = orderName
  400.     
  401.     '
  402.     ' create the Customer City level
  403.     '   the Customer City level contains all of the cities
  404.     On Error GoTo Err_Create
  405.     Set dsoLevel = dsoDimension.Levels.AddNew("Customer City")
  406.     
  407.     ' set the level type
  408.     dsoLevel.LevelType = levRegular
  409.     
  410.     ' "customer_city" column contains members for this level
  411.     dsoLevel.MemberKeyColumn = sLQuote & "customer" & sRQuote & "." & _
  412.                                sLQuote & "city" & sRQuote
  413.  
  414.     ' there are 109 distinct cities in the "customer" table
  415.     dsoLevel.EstimatedSize = 109
  416.     
  417.     ' this level does not contains unique members
  418.     dsoLevel.IsUnique = False
  419.     
  420.     ' DSO needs to know what is the type and maximum size of the members keys
  421.     dsoLevel.ColumnType = adChar
  422.     dsoLevel.ColumnSize = 20            ' the longest city in the table
  423.                                         ' can fit in 20 characters
  424.     
  425.     ' we want the cities ordered by Name
  426.     dsoLevel.Ordering = orderName
  427.     
  428.     ' save the dimension definition in the metadata repository
  429.     On Error GoTo Err_Update
  430.     dsoDimension.Update
  431.     
  432.     ' unlock the dimension
  433.     dsoDimension.UnlockObject
  434.     
  435.     
  436.     '
  437.     '   add the private dimension to the cube
  438.     '
  439.     
  440.     ' lock the cube for writing
  441.     On Error GoTo Err_LockCube
  442.     m_dsoCube.LockObject olaplockWrite, _
  443.                          "DSO Sample is adding a dimension to the cube"
  444.                          
  445.     ' add the private dimension to the cube
  446.     m_dsoCube.Dimensions.AddNew "Sales^Customer"
  447.     
  448.     ' update the cube's FromClause and JoinClause
  449.     m_dsoCube.FromClause = m_dsoCube.FromClause & ", " & sLQuote & "customer" & sRQuote
  450.     m_dsoCube.JoinClause = m_dsoCube.JoinClause & " AND " & _
  451.                 "(" & _
  452.                     sLQuote & "sales_fact_1998" & sRQuote & "." & sLQuote & "customer_id" & sRQuote & _
  453.                     " = " & _
  454.                     sLQuote & "customer" & sRQuote & "." & sLQuote & "customer_id" & sRQuote & _
  455.                 ")"
  456.                 
  457.     ' save the cube definition in the metadata repository
  458.     On Error GoTo Err_UpdateCube
  459.     m_dsoCube.Update
  460.     
  461.     ' unlock cube
  462.     m_dsoCube.UnlockObject
  463.  
  464. Exit Sub
  465.  
  466. Err_Create:
  467.     ' Failed to create the object.
  468.     ' Possible reasons:
  469.     '   - the DSO database object is being locked by another DSO application
  470.     '       a DSO object is locked while AddNew method is executing on
  471.     '       one of its collections (Datasources, MDCustomers, Dimensions...)
  472.     '   - the metadata repository is unreachable
  473.  
  474. Err_Lock:
  475.     ' Failed to lock the dimension
  476.     ' Possible reasons:
  477.     '   - the object is already locked by another application
  478.     '   - the machine on which OLAP server is running is not reachable
  479.  
  480. Err_Update:
  481.     ' Failed to persist the dimension definition in the metadata repository
  482.     ' Possible reasons:
  483.     '   - the metadata repository is unreachable
  484.     '       you can see where the metadata repository resides by looking
  485.     '       up the following registry entry:
  486.     '       HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
  487.     '           Repository Connection String
  488.     '   - the DSO dimension object is being locked by another DSO application
  489.     '       it is not possible for two DSO apps to persist the same object
  490.     '       at the same time
  491.     '       it is not possible to persist a DSO object, it another DSO app
  492.     '       has explicitly locked it
  493.  
  494. Err_UpdateCube:
  495.     ' unlock cube
  496.     m_dsoCube.UnlockObject
  497.     
  498. Err_LockCube:
  499.     ' Failed to lock the cube
  500.     
  501.     MsgBox "Create private dimension Customer failed" & vbCrLf & Err.Description
  502. End Sub
  503.  
  504.  
  505. '
  506. '   CreatePartition - create new partition in the Sales cube
  507. '                     use "sales_fact_1997" as the partition's fact table
  508. '
  509. Public Sub CreatePartition()
  510.     ' lock the cube for writing
  511.     ' so that no other application can modify it
  512.     
  513.     On Error GoTo Err_Lock
  514.     m_dsoCube.LockObject olaplockWrite, _
  515.                          "DSOSample is adding new partition to the cube"
  516.         
  517.     ' NOTE: we do not have to lock the partition after adding it to the cube
  518.     '       by adding it to the locked cube, the partition is also locked
  519.     
  520.     ' create the new partition
  521.     On Error GoTo Err_Create
  522.     Dim dsoPartition As DSO.MDStore
  523.     Set dsoPartition = m_dsoCube.MDStores.AddNew("Sales 1997")
  524.     
  525.     ' NOTE: since the partition will be using the same datasource as the cube,
  526.     '       we don't have to set the partition's datasource, it is by default
  527.     '       the same as the cube's
  528.     
  529.     ' get the quoting characters from the datasource
  530.     Dim sLQuote As String, sRQuote As String
  531.     sLQuote = dsoPartition.DataSources(1).OpenQuoteChar
  532.     sRQuote = dsoPartition.DataSources(1).CloseQuoteChar
  533.     
  534.     ' set the partition fact table
  535.     dsoPartition.SourceTable = sLQuote & "sales_fact_1997" & sRQuote
  536.  
  537.     ' set the number of records in the fact table that will be loaded into
  538.     ' the cube
  539.     dsoPartition.EstimatedRows = 86837
  540.  
  541.     ' set the storage mode
  542.     ' this partition will be ROLAP 0 aggregations
  543.     dsoPartition.OlapMode = olapmodeRolap
  544.     
  545.     ' set the prefix for the aggregation tables
  546.     dsoPartition.AggregationPrefix = "Sales1997_"
  547.  
  548.     ' set the partition's FromClause and JoinClause
  549.     dsoPartition.FromClause = StringReplace(m_dsoCube.FromClause, _
  550.                                             m_dsoCube.SourceTable, _
  551.                                             dsoPartition.SourceTable)
  552.     
  553.     dsoPartition.JoinClause = StringReplace(m_dsoCube.JoinClause, _
  554.                                             m_dsoCube.SourceTable, _
  555.                                             dsoPartition.SourceTable)
  556.                                             
  557.     ' if you want to limit the records from the partition's fact table
  558.     ' that are to be loaded into the partition, you can use the
  559.     ' SourceTableFilter property.
  560.     ' Ex: dsoPartition.SourceTableFilter = "sales_fact_1997"."time_id" = <value>"
  561.     
  562.     ' set the partition data slice
  563.     ' the data slice is a hint for the server
  564.     ' the server will not bother sending a query to this partition
  565.     '   if it notices that based on the data slice, the query does
  566.     '   not require any data from this partition
  567.     ' set the slice to year 199
  568.     ' the slice value is the member key, not member name
  569.     Dim dsoPartitionDimension As DSO.Dimension
  570.     Dim dsoPartitionLevel As DSO.Level
  571.     Set dsoPartitionDimension = dsoPartition.Dimensions("Time")
  572.     Set dsoPartitionLevel = dsoPartitionDimension.Levels("All")
  573.     dsoPartitionLevel.SliceValue = "All Years"
  574.     Set dsoPartitionLevel = dsoPartitionDimension.Levels("Year")
  575.     dsoPartitionLevel.SliceValue = "1997"
  576.        
  577.     ' save the partition definition in the metadata repository
  578.     On Error GoTo Err_Update
  579.     dsoPartition.Update
  580.         
  581.     ' unlock the cube
  582.     m_dsoCube.UnlockObject
  583.         
  584. Exit Sub
  585.  
  586. Err_Lock:
  587.     ' Failed to lock the cube
  588.     ' Possible reasons:
  589.     '   - the cube is already locked by another application
  590.     '   - the machine on which OLAP server is running is not reachable
  591.  
  592. Err_Create:
  593.     ' Failed to create the partition.
  594.     ' Possible reasons:
  595.     '   - the metadata repository is unreachable
  596.     
  597. Err_Update:
  598.     ' Failed to persist the partition definition in the metadata repository
  599.     ' Possible reasons:
  600.     '   - the metadata repository is unreachable
  601.     '       you can see where the metadata repository resides by looking
  602.     '       up the following registry entry:
  603.     '       HKEY_LOCAL_MACHINE\Software\Microsoft\OLAP Server\Server Connection Info
  604.     '           Repository Connection String
  605.     '   - the DSO datasource object is being locked by another DSO application
  606.     '       it is not possible for two DSO apps to persist the same object
  607.     '       at the same time
  608.     '       it is not possible to persist a DSO object, it another DSO app
  609.     '       has explicitly locked it
  610.     
  611.     
  612.     ' unlock the cube
  613.     m_dsoCube.UnlockObject
  614.     
  615.     MsgBox "Create partition failed" & vbCrLf & Err.Description
  616.  
  617. End Sub
  618.  
  619.  
  620. '
  621. '   StringReplace - helper function for updating partition properties
  622. '
  623. Public Function StringReplace(Source As String, search As String, replace As String) As String
  624.     Dim start As Integer
  625.     Dim pos As String
  626.     Source = " " & Source & " "
  627.     start = 1
  628.     While InStr(start, UCase(Source), UCase(search)) > 0
  629.         pos = InStr(start, UCase(Source), UCase(search))
  630.         Source = Left(Source, pos - 1) & replace & Mid(Source, pos + Len(search))
  631.         start = pos + Len(replace)
  632.     Wend
  633.     StringReplace = Trim(Source)
  634. End Function
  635.  
  636.