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;


}

posted @ 2015-10-23 15:59  情难舍,人难留  阅读(258)  评论(0编辑  收藏  举报