我正在尝试使用ADOMD.NET从云中的已部署模型中检索Azure Analysis Services中的数据。代码片段如下所示,但我收到了ConnectionString无效的错误。
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();
}
}
}
}
}发布于 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
接下来,您需要将连接字符串更改为:
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,以确保在部署了多个数据库时连接到正确的数据库。
发布于 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://数据源
非常恼人的是,微软的网站上没有文档,也没有与该问题相关的支持。然而,这将解决您的问题。
https://stackoverflow.com/questions/41739717
复制相似问题