IAdoMdConnection.Command

Syntax

Command(Text: String): IDalCommand;

Parameters

Text.The MDX query text, with which the object is initialized.

Description

The Command method initializes an object that enables the user to work with server with the MDX queries.

Example

Executing the example requires that the repository contains an ADOMD catalog with the ADOMDTest identifier.

Sub UserProc;
Var
    MB: IMetabase;
    Catalog: IAdoMdCatalogInstance;
    Connection: IAdoMdConnection;
    sMDX: String;
    Command: IDalCommand;
    ResultCursor: IDalCursor;
    CFields: IDalCursorFields;
    CField: IDalCursorField;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    Catalog := MB.ItemById("ADOMDTest").Open(NullAs IAdoMdCatalogInstance;
    Connection := Catalog.Connection;
    sMDX := "SELECT ...";
    Command := Connection.Command(sMDX);
    //MDX query execution
    Command.Execute;
    //Obtaining execution results
    ResultCursor := Command.CreateCursor;
    CFields := ResultCursor.Fields;
    While Not ResultCursor.Eof Do
        For i := 0 To CFields.Count - 1 Do
            CField := CFields.Item(i);
            Debug.WriteLine(CField.Name + " | " + CField.Value);
        End For;
        ResultCursor.Next;
    End While;
End Sub UserProc;

The command, used to execute multidimensional queries, is created on executing the example. The cursor, containing the result, is created after the query execution. The results are displayed in the development environment console.

See also:

IAdoMdConnection