Листинг 2
Private Sub Command2_Click()
Dim Cst As New ADOMD.Cellset
Dim Cnn As New ADODB.Connection
Cnn.ConnectionString = "Provider=MSOLAP.2;Persist Security Info=True;”_
+”User ID=sa;Data Source=MAINDESK;Initial Catalog=NorthWind_OLAP"
Cnn.Open
Text2.Text = vbTab & vbTab
Set cst.ActiveConnection = cnn
cst.Source = Text1.Text
On Error GoTo Err
cst.Open
For i = 0 To cst.Axes(0).Positions.Count - 1
Text2.Text = Text2.Text & cst.Axes(0).Positions(i).Members(0).Caption_
& vbTab
Next i
Text2.Text = Text2.Text & vbCrLf & vbCrLf
For j = 0 To cst.Axes(1).Positions.Count - 1
Text2.Text = Text2.Text & cst.Axes(1).Positions(j).Members(0).Caption_
& vbTab
For k = 0 To cst.Axes(0).Positions.Count - 1
Text2.Text = Text2.Text & vbTab & cst(k, j).FormattedValue
Next k
Text2.Text = Text2.Text & vbCrLf
Next j
Exit Sub
Err:
MsgBox ("Invalid Query")
End Sub