2

我正在使用Microsoft.AnalysisServices.AdomdClient.dll v13.0.0.0 从 C# 代码访问 Power BI 数据集。一直在尝试各种连接字符串,但总是出现异常......

var connectionString = @"Provider=MSOLAP.7;Integrated Security=;Identity Provider=AAD;Data Source=https://analysis.windows.net/powerbi/api;Initial Catalog=XXXX-XXXX-GUID;Location=https://wabi-us-north-central-redirect.analysis.windows.net/xmla?vs=sobe_wowvirtualserver&db=XXX-XXX-GUID;MDX Compatibility= 1; MDX Missing Member Mode= Error; Safety Options= 2; Update Isolation Level= 2;User ID=my@workemail.com;Password=my_pswd;";
var conn = new AdomdConnection(connectionString);
conn.Open(); //throws here

上面的连接字符串产生错误

“连接超时或丢失。”

这个字符串基于我从 Power BI 下载的 .odc 文件,它在 Excel 中运行良好 - 数据被加载到数据透视表等中(我猜 Excel 使用 COM 驱动程序?)

如果我设置 Integrated Security = SSPIor Basic,客户端会抛出另一个错误,说它们都不能与 HTTP 一起使用。

我的代码中缺少什么?我正在寻找 Power BI 连接字符串的工作示例。谢谢!

更新: 上面的连接字符串有一个内部异常:“无法解析远程名称:'analysis.windows.net'” 当我单击 ANALYZE IN EXCEL 时,此 url 是 Power BI 放入 odc 文件的内容。我应该使用什么 url 来连接来自 .Net 代码的数据?

4

1 回答 1

0

我发现要连接到 power bi 我需要 19.9.0 版本,连接会提示输入用户名和密码。

https://www.nuget.org/packages/Microsoft.AnalysisServices.AdomdClient.retail.amd64 https://www.nuget.org/packages/Microsoft.AnalysisServices.retail.amd64

connectionString= $"Provider=MSOLAP;Data Source=powerbi://api.powerbi.com/v1.0/myorg/{workspacename};";
于 2020-08-13T01:37:02.723 回答