Search code examples
c#adomd.net

AdomdConnectionException was unhandled - The connection string is not valid


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

I am using the above code to connect to server and then I am further running MDX queries using this.The problem is the error I am getting - "The connection string is not valid" at line

connection.open(); 

Are the settings name incorrect which I am using in my connection string?Can someone help me figure out what is wrong in my connection string ?

The stack trace is as follows: enter image description here


Solution

  • I found my answer here. The unofficial package worked just fine . So I installed the reference Unofficial.Microsoft.AnalysisServices.AdomdClient and so the problem was not in the connection string but in the package.