首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ADOMD.NET连接到Azure Analysis时出现连接字符串错误

使用ADOMD.NET连接到Azure Analysis时出现连接字符串错误
EN

Stack Overflow用户
提问于 2017-01-19 18:40:07
回答 2查看 2.1K关注 0票数 2

我正在尝试使用ADOMD.NET从云中的已部署模型中检索Azure Analysis Services中的数据。代码片段如下所示,但我收到了ConnectionString无效的错误。

代码语言:javascript
复制
using Microsoft.AnalysisServices.AdomdClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test_Analysis_Service_retrieval
{
    class Program
    {
        static void Main(string[] args)
        {
            string queryString = @"SELECT [MAP_CUST_NAME] FROM [AAS_MAPLOOKUP] where [MAP_ACT_NO] = '120000810';";
            string connectionString = @"Data Source=asazure://westus.asazure.windows.net/bbacloud;UserName=xyz@gmail.com;Password=ABC@123;";

            using (AdomdConnection connection = new AdomdConnection(connectionString))
            {
                CellSet AASOutput = null;
                System.Xml.XmlReader reader = null;
                try
                {
                    string s = connection.ConnectionString;
                    Console.WriteLine(s);
                    connection.Open();
                    AdomdCommand command = new AdomdCommand(queryString, connection);
                    command.CommandTimeout = 100000;
                    reader = command.ExecuteXmlReader();
                    Console.WriteLine(reader.ReadOuterXml());
                }
                catch(Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    connection.Close();
                }
            }
        }
    }
}
EN

回答 2

Stack Overflow用户

发布于 2017-01-19 23:17:23

您需要做的第一件事是确保安装了最新的ADOMD.NET (AdomdClient)。从here下载。安装后,请确保您的C#项目在以下位置对其进行了引用:

C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.AnalysisServices.AdomdClient\v4.0_13.0.0.0__89845dcd8080cc91\Microsoft.AnalysisServices.AdomdClient.dll

接下来,您需要将连接字符串更改为:

代码语言:javascript
复制
string connectionString = @"Data Source=asazure://westus.asazure.windows.net/bbacloud;User ID=user@domain.com;Password=pwdHere;Initial Catalog=DatabaseNameHere";

注意几件事。首先,它是用户ID而不是UserName。其次,用户需要是Azure Active Directory用户(组织帐户,而不是个人LiveID)。最后,您需要指定Initial Catalog,以确保在部署了多个数据库时连接到正确的数据库。

Nuget更新:最新版本可在here上获得。或者,如果您正在构建.NET核心应用程序,请使用this

票数 2
EN

Stack Overflow用户

发布于 2017-07-04 10:23:44

事实证明,这个问题是由于AdomdClient的RTM版本实际上不支持Azure Analysis Services的RTM版本。因此,需要以下Nuget包:

https://github.com/ogaudefroy/Unofficial.Microsoft.AnalysisServices.AdomdClient

一旦你移除/卸载了Microsoft.AnalysisServices.AdomdClient.12.0.2000.8的12版( RTM版本)并安装了上面的AdomdClient,一切都很正常。简而言之,v12版本没有内置代码来解析asazure://数据源

非常恼人的是,微软的网站上没有文档,也没有与该问题相关的支持。然而,这将解决您的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41739717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档