Bugaboo
Bugaboo

Reputation: 971

Programatically connect and refresh tabular data model on SQL Sever Analysis Service

I'm very new to SSAS. I have a system where I use C# to populate a SQL server table from a C# DataTable.

I have a SSAS setup that uses this SQL server table as a data source. How, do I connect to this SSAS and refresh the model from C#? I essentially want to do this connect/refresh thing from my code after I'm done appending the C# DataTable to the SQL Server table.

On a separate note, is it possible to eliminate the middle man here - SQL server table and directly populate the C# DataTable to a SSAS tabular data model?

Upvotes: 3

Views: 3585

Answers (1)

Daryl Wenman-Bateson
Daryl Wenman-Bateson

Reputation: 3964

Add a reference to Microsoft.AnalysisServices (you can find it in SQL Server install directory) and then enter the following code.

using Microsoft.AnalysisServices;

...

Server server = new Server();

server.Connect("Data source=YourServerName;Timeout=6000;Integrated Security=SSPI");

Database database = server.Databases.FindByName("YourCubeName");
database.Process(ProcessType.ProcessFull);

you may have to adjust the Timeout depending on your cube processing time

Upvotes: 3

Related Questions