【问题标题】:How do I add a structured ODBC data source to a tabular model using the AMO tabular library如何使用 AMO 表格库将结构化 ODBC 数据源添加到表格模型
【发布时间】:2019-06-23 08:56:10
【问题描述】:

将结构化 ODBC 数据源添加到我的模型会导致错误。

我想使用 Microsoft.AnalysisServices.Tabular 库,使用结构化(即 M / Power Query)、非传统(即 ProviderDataSource)数据源,在兼容级别 1400 的 SQL Analysis Services 服务器上生成表格模型。 我使用 NuGet 包 Microsoft.AnalysisServices.retail.amd64 (16.3.0) 安装了该库。

这是我的数据源定义。

                myDatabase.Model.DataSources.Add(new StructuredDataSource()
                {
                    Name = "ODBC",
                    Description = "An structured ODBC data source definition",
                    ConnectionDetails = new ConnectionDetails()
                    {
                        Protocol = DataSourceProtocol.Odbc
                    },
                    Credential = new Credential()
                    {
                        AuthenticationKind = AuthenticationKind.UsernamePassword,
                        EncryptConnection = false,
                        Username = "MYUSERNAME",
                        Password = "MYPASSWORD"
                    }
                }

当我运行这段代码时,我得到:

COM error: Microsoft.Data.Mashup; The given data source reference is not a valid data source.

它并没有给我任何指示去哪里看或具体有什么问题。我怀疑定义需要一个服务器地址,但是无法根据文档设置ConnectionDetails对象的地址属性。

ConnectionDetails.Address Property

Address of this connection. It can't be set, instead it should be modified directly.

【问题讨论】:

    标签: c# ssas-tabular analysisservices


    【解决方案1】:

    在查看我的问题并进一步调查文档时,我构建了这个解决方案。对于那些遇到同样问题的人,我认为最好将其发布在这里。

    Credential credential = new Credential()
    {
        AuthenticationKind = AuthenticationKind.UsernamePassword,
        EncryptConnection = false,
        Username = "MYUSERNAME",
        Password = "MYPASSWORD" // Please note that this won't persist.
    };
    
    ConnectionDetails connectionDetails = new ConnectionDetails("{ 'protocol': 'odbc', 'address': { 'options': { 'dsn': 'MYODBCDSN' } }, 'authentication': null, 'query': null }");
    
    dbWithDataSource.Model.DataSources.Add(new StructuredDataSource()
    {
        Name = "ODBC",
        Description = "An ODBC structured (ie. non-legacy) data source definition",
        ConnectionDetails = connectionDetails,
        Credential = credential,
        Options = new DataSourceOptions( "{ 'hierarchicalNavigation': true }" )
    }
    

    我基本上所做的就是在 ConnectionDetails 构造函数中传入一个 JSON 字符串,同时设置“只读”地址属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-23
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 1970-01-01
      相关资源
      最近更新 更多