Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Runtime Public Class ScriptMain Public Sub Main() Dim ExecutionSuccessfull As Boolean = True ' If true, package executed without errors Dim sProcessType As String = "ProcessFull" Dim oConnection As ConnectionManager oConnection = Dts.Connections("DM") Dim sServer As String = CStr(oConnection.Properties("ServerName").GetValue(oConnection)) Dim sDatabaseID As String = CStr(oConnection.Properties("InitialCatalog").GetValue(oConnection)) Dim oServer As New Microsoft.AnalysisServices.Server oServer.Connect(sServer) ' connect to the server and start scanning down the object hierarchy Dim oDB As Microsoft.AnalysisServices.Database = oServer.Databases.FindByName(sDatabaseID) If oDB Is Nothing Then ExecutionSuccessfull = False GoTo Done Else Dim oDim As Microsoft.AnalysisServices.Dimension oServer.CaptureXml() = True ' Start capturing XML. For Each oDim In oDB.Dimensions ' This will generate XMLA, but because CaptureXML is True, will not execute it! oDim.Process(Microsoft.AnalysisServices.ProcessType.ProcessFull) Next oServer.CaptureXml() = False ' Stop capturing XML ' Execute captured XML. First parameter Transactional, second parameter Parallel, third optional parameter: processAffected ' These are very important parameters! Dim oResults As Microsoft.AnalysisServices.XmlaResultCollection Dim oResult As Microsoft.AnalysisServices.XmlaResult oResults = oServer.ExecuteCaptureLog(True, True) Dim oMessage As Microsoft.AnalysisServices.XmlaMessage 'Log the errors and warnings For Each oResult In oResults For Each oMessage In oResult.Messages If oMessage.GetType.Name = "XmlaError" Then 'The processing failed ExecutionSuccessfull = False Else 'It's just a warning. ExecutionSuccessfull = True ' if you want to fail on warning, change this to False End If Next oMessage Next oResult End If Done: oServer.Disconnect() ' disconnect from the server -- we are done If ExecutionSuccessfull Then Dts.TaskResult = Dts.Results.Success Else Dts.TaskResult = Dts.Results.Failure End If End Sub End Class