【问题标题】:Querying OLAP Cubes via ASHX Service通过 ASHX 服务查询 OLAP Cube
【发布时间】:2016-08-25 18:49:31
【问题描述】:

我正在使用以下代码在 C# 中执行查询:

        // Create Connection String
        AdomdConnection testConnection = new AdomdConnection("Data Source=*****;User ID=******;Provider=MSOLAP.6;Persist Security Info=True;Impersonation Level=Impersonate;Password=******");

        // Test Open
        testConnection.Open();

        // Make Query
        AdomdCommand cmd = new AdomdCommand(@"SELECT { [Measures].[Payment Amount] } ON COLUMNS,
                                             { [Charging Low Orgs].[Charging Division].[Charging Division] } ON ROWS 
                                              FROM [Payments]", testConnection);

        AdomdDataReader dataReader = cmd.ExecuteReader();

        // Close Connection
        testConnection.Close();

我在 cmd.ExecuteReader() 调用中不断收到此错误:

{"用于分析解析器的 XML:未指定 CurrentCatalog XML/A 属性。"}

我能找到的唯一与此相关的文献是查询未解析,因为未设置模拟,但我在连接字符串中指定了这一点。

另一篇我认为不相关的文章说在 Excel 上启用 BAM,但我在 Excel 中没有该选项,我看不出这会对 Web 服务产生什么影响。

请帮忙!

【问题讨论】:

    标签: c# asp.net mdx olap ashx


    【解决方案1】:

    以下示例在连接字符串中包含一个目录参数:

    static void Main(string[] args)
            {
                AdomdConnection conn = new AdomdConnection(
                    "Data Source=localhost;Catalog=Adventure Works DW Standard Edition");
                conn.Open(  );
    
                string commandText = "SELECT {[Measures].[Sales Amount], " +
                    "[Measures].[Gross Profit Margin]} ON COLUMNS, " +
                    "{[Product].[Product Model Categories].[Category]} ON ROWS " +
                    "FROM [Adventure Works] " +
                    "WHERE ([Sales Territory Country].[United States])";
    
                AdomdCommand cmd = new AdomdCommand(commandText, conn);
                AdomdDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
    

    【讨论】:

    • 谢谢!我稍微混淆了连接字符串,但我认为目录将假定为在数据源中带有“\”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多