c# - 通过 ASHX 服务查询 OLAP 多维数据集

标签 c# asp.net mdx olap ashx

我正在使用以下代码在 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 for Analysis parser: The CurrentCatalog XML/A property was not specified."}

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

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

请帮忙!

最佳答案

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

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);

关于c# - 通过 ASHX 服务查询 OLAP 多维数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39152710/

相关文章:

C# 将旧接口(interface)函数携带到新接口(interface)

将 div 移动到另一个 div 中时,jQuery 显示/隐藏不起作用

c# - 删除析构函数中的事件处理程序,以防发布者和订阅者相互引用

sql-server - 获取一个月中的天数 - mdx

c# - 将我的网站发布到我的本地磁盘导致异常显示路径包括我的本地磁盘

c# - C#中的多重继承

c# - PdfPCell 中的右对齐文本

c# - 开关盒的吸气功能?

sql-server - SSAS MDX WHERE 子句语法 - 从同一层次结构中过滤多个值

parent-child - 如何使用一元运算符对排列在父子层次结构中的数据执行 YTD 聚合?