So I've installed AMO and created the following console application:
using System;
using Microsoft.AnalysisServices;
using Microsoft.AnalysisServices.Tabular;
namespace procesarCuboSSAST
{
class Program
{
static void Main(string[] args)
{
try
{
string ConnectionString = "Data source=SERVER\\BI";
using (Microsoft.AnalysisServices.Tabular.Server server = new Microsoft.AnalysisServices.Tabular.Server())
{
server.Connect(ConnectionString);
Microsoft.AnalysisServices.Tabular.Database Db = server.Databases["TestModel"]; //Connect to the DB
Model m = Db.Model;
m.RequestRefresh(Microsoft.AnalysisServices.Tabular.RefreshType.Full);
m.SaveChanges();
}
Console.WriteLine("Press Enter to close this console window.");
Console.ReadLine();
}
catch (Exception e)
{
Console.Write(e.Message.ToString());
Console.WriteLine("Press Enter to close this console window.");
Console.ReadLine();
}
}
}
}
However, I'm getting error: "object reference not set to an instance of an object"
I can correctly list the databases and models in the SSAS instance with
foreach (Database db in server.Databases)
{
Console.WriteLine("Properties for database {0}:", db.Name);
...
My server is SSAS 2014 Enterprise (tabular) (12.0.5000.0)
What compatibility level is the Tabular model that you're attempting to process? The Model class is only for Tabular models at level 1200 or above. The Database class will let you view models at a lower compatibility level, but not modify them, which is why you can list the SSAS databases on the instance but not process them. The links below contain addition details on these classes.
Model Class
Database Class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With