home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmVBADOSimple
- Caption = "VB ADO Simple"
- ClientHeight = 1200
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4005
- LinkTopic = "Form1"
- ScaleHeight = 1200
- ScaleWidth = 4005
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton cmdCellSettoDebugWindow
- Caption = "Write Cell Set info to Debug Window"
- Height = 510
- Left = 270
- TabIndex = 0
- Top = 315
- Width = 3345
- End
- Attribute VB_Name = "frmVBADOSimple"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub cmdCellSettoDebugWindow_Click()
- Dim cat As New ADOMD.Catalog
- Dim cst As New ADOMD.Cellset
- Dim i As Integer
- Dim j As Integer
- Dim strServer As String
- Dim strSource As String
- Dim strColumnHeader As String
- Dim strRowText As String
- On Error GoTo Error_cmdCellSettoDebugWindow_Click
- Screen.MousePointer = vbHourglass
- '*--------------------------------------------------------------------------------------------------
- '* Set Server to Local Host
- '*--------------------------------------------------------------------------------------------------
- strServer = "LOCALHOST"
- '*--------------------------------------------------------------------------------------------------
- '* Set MDX query string Source
- '*--------------------------------------------------------------------------------------------------
- strSource = strSource & "SELECT "
- strSource = strSource & "{[Measures].members} ON COLUMNS,"
- strSource = strSource & "NON EMPTY [Store].[Store City].members ON ROWS"
- strSource = strSource & " FROM Sales"
- '*--------------------------------------------------------------------------------------------------
- '* Set Active Connection
- '*--------------------------------------------------------------------------------------------------
- cat.ActiveConnection = "Data Source=" & strServer & ";Provider=msolap;"
- '*--------------------------------------------------------------------------------------------------
- '* Set Cell Set source to MDX query string
- '*--------------------------------------------------------------------------------------------------
- cst.Source = strSource
- '*--------------------------------------------------------------------------------------------------
- '* Set Cell Sets active connection to current connection
- '*--------------------------------------------------------------------------------------------------
- Set cst.ActiveConnection = cat.ActiveConnection
- '*--------------------------------------------------------------------------------------------------
- '* Open Cell Set
- '*--------------------------------------------------------------------------------------------------
- cst.Open
- '*--------------------------------------------------------------------------------------------------
- '* Allow space for Row Header Text
- '*--------------------------------------------------------------------------------------------------
- strColumnHeader = vbTab & vbTab & vbTab & vbTab & vbTab & vbTab
- '*--------------------------------------------------------------------------------------------------
- '* Loop through Column Headers
- '*--------------------------------------------------------------------------------------------------
- For i = 0 To cst.Axes(0).Positions.Count - 1
- strColumnHeader = strColumnHeader & cst.Axes(0).Positions(i).Members(0).Caption & vbTab & vbTab & vbTab & vbTab
- Next
- Debug.Print vbTab & strColumnHeader & vbCrLf
- '*--------------------------------------------------------------------------------------------------
- '* Loop through Row Headers and Provide data for each row
- '*--------------------------------------------------------------------------------------------------
- strRowText = ""
- For j = 0 To cst.Axes(1).Positions.Count - 1
- strRowText = strRowText & cst.Axes(1).Positions(j).Members(0).Caption & vbTab & vbTab & vbTab & vbTab
- For k = 0 To cst.Axes(0).Positions.Count - 1
- strRowText = strRowText & cst(k, j).FormattedValue & vbTab & vbTab & vbTab & vbTab
- Next
- Debug.Print strRowText & vbCrLf
- strRowText = ""
- Next
-
- Screen.MousePointer = vbDefault
- Exit Sub
- Error_cmdCellSettoDebugWindow_Click:
- Beep
- Screen.MousePointer = vbDefault
- MsgBox "The Following Error has occurred:" & vbCrLf & Err.Description, vbCritical, " Error!"
- Exit Sub
- End Sub
-