如何使用.NET将数据从MS SQL导入表格格式

时间:2019-05-09 08:57:47

标签: .net azure import ssas

那么可以使用.net库adom.net将数据从ms sql导入到表格模型ssas吗?到目前为止,我知道可以使用数据导入向导,但是也许可以不使用向导而进行操作,而是使用.net进行制作?

1 个答案:

答案 0 :(得分:1)

我不确定您是要刷新数据还是要向模型添加全新的数据源。但是,.net库中的任何一个都非常简单。

    static void Main(string[] args)
    {
        Server server = new Server();

        server.Connect("Data source=YourSSASServerName;Timeout=7200000;Integrated Security=SSPI");

        Database database = server.Databases.FindByName("YourCubeDBName");

        //
        //process database (load in fresh data from SQL)
        //
        database.Process(ProcessType.ProcessFull);





        //
        // add new data source to model (SQL server)
        //
        database.Model.DataSources.Add(new ProviderDataSource()
        {
            Name = "SQL Server Data Source Example",
            Description = "A data source definition that uses explicit Windows credentials for authentication against SQL Server.",
            ConnectionString = "Provider=SQLNCLI11;Data Source=localhost;Initial Catalog=AdventureWorks2014;Integrated Security=SSPI;Persist Security Info=false",
            ImpersonationMode = Microsoft.AnalysisServices.Tabular.ImpersonationMode.ImpersonateAccount,
            Account = @".\Administrator",
            Password = "P@ssw0rd",
        });


        // 
        // Add the new database object to the server's  
        // Databases connection and submit the changes 
        // with full expansion to the server. 
        // 
        server.Databases.Add(database);
        database.Update(UpdateOptions.ExpandFull);
    }
相关问题