1
     public static void connect()
     {   
        try
        {
            string connectionStringStaging = @"Data Source=<server_name>;Catalog=<catalog_name>;User ID=<user_name>;Password=<my_password>";
            string commandText = @"SELECT NON EMPTY { [Measures].[# Opptys moved to Committed] } ON COLUMNS FROM [Model] 
                                    CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS";
            AdomdConnection connection = new AdomdConnection(connectionStringStaging);
            connection.Open();
            AdomdCommand cmd = new AdomdCommand(commandText);
            cmd.Connection = connection;
            using (var reader = cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    Console.WriteLine(reader[0]);
                }
            }
        }
        catch (AdomdConnectionException ex)
        {
            Console.WriteLine("Error : " + ex.ToString());
        }
     }

我正在使用上面的代码连接到服务器,然后我正在使用它进一步运行 MDX 查询。问题是我得到的错误 - “连接字符串无效”在行

connection.open(); 

我在连接字符串中使用的设置名称是否不正确?有人可以帮我弄清楚我的连接字符串有什么问题吗?

堆栈跟踪如下: 在此处输入图像描述

4

2 回答 2

0

请查阅 Microsoft 的以下文档:https ://msdn.microsoft.com/en-us/library/microsoft.analysisservices.adomdclient.adomdconnection.connectionstring.aspx

您还可以在此处找到一些连接字符串示例:https ://www.connectionstrings.com/adomd-net/

希望这可以帮助您解决问题。

于 2017-07-03T11:15:14.163 回答
0

我在这里找到了答案。非官方的包工作得很好。所以我安装了参考Unofficial.Microsoft.AnalysisServices.AdomdClient,所以问题不在于连接字符串,而在于包。

于 2017-07-04T04:38:27.307 回答