SharePoint 通过Oledb链接本地SSAS中的CUBE
public static OleDbConnection Connection()
{
string connectionstring = "Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=True;" +
"Initial Catalog=“数据库名”;Data Source=“服务器名”;MDX Compatibility=1;" +
"Safety Options=2;MDX Missing Member Mode=Error";
SPSecurity.RunWithElevatedPrivileges(delegate() //要加上这句话 获取最高权限 不然会出现没有权限的错误
{
if (connection == null)
{
connection = new OleDbConnection(connectionstring);
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
});
return connection;
}