开发者

Making a dropdown using Analysis Cube Data

So I am working on a project that requires me to make a dropdown using the data from analysis service cube. This is what i have come up with by googling.

protected void Page_Load(object sender, EventArgs e)
    {   DataTable dt = new DataTable();
        AdomdConnection conn = new AdomdConnection();
        conn.ConnectionString = "Data Source=RRLR87G4XE-1;Provider=MSOLAP";
        conn.Open();

        AdomdCommand cmd = new AdomdCommand();
        cmd = conn.CreateCommand();
        cmd.Parameters.Add("DimProductRegion", "Bike");
        cmd.CommandText = "SELECT {[Dim Product].[Region].children} ON ROWS, {} ON COLUMNS FROM [Adventure Works]";

        AdomdDataAdapter da = new AdomdDataAdapter(cmd);开发者_StackOverflow中文版
        da.Fill(dt);


        ddlRegionFilter.DataSource = dt;
        ddlRegionFilter.DataTextField = "ParameterCaption";
        ddlRegionFilter.DataValueField = "ParameterValue";
        ddlRegionFilter.DataBind();}

but the problem is that it wouldn't display the results on the drop down. the drop down is just empty.

<asp:DropDownList ID="ddlRegionFilter" runat="server" AutoPostBack=true >
</asp:DropDownList>


I think your issue might be becuase your MDX is not returning any values. Whilst the cellset returned will list the regions, the region names will be in a sort of header (similar to a SQL column name, or field name).

Debug your code, and have a look what is inside the datatable. No rows?

The main body of the datatable will not contain any values (numbers or text) because you have said {} ON COLUMNS. You may still be able to get what you are after by changing what you connect to .DataTextField but there is another way.

ADOMD provides a way to interrogate an OLAP cube to find out what dimensions it has, what members are in each dimension, without asking it for any values (in a way, you can ask it for text, but no numbers!). For example, you can ask it to list the names of measures available, without asking it what the value of a measure is. You want the ADOMD Catalog oject in this case. It would list all members of the Product dimension at the Region level, if you asked it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜