SSAS: 如何在ADOMDConnection中指定会话ID


SSAS的所有客户端操作,不管你用什么工具,都将转换为XMLA语句传递给服务器。我们用的比较多的是ADOMD.NET Client这套接口来访问的。

  在XMLA操作中,有一个非常重要的部分就是会话(SESSION),客户端与服务器端之间的通讯是需要用会话来维护的,而且SSAS有很多对象是可以在会话级别访问的,例如计算成员和集,都有会话级别的部分。

  那么,如何在ADOMDConnection中指定或者获取SessionID呢,下面的代码可以供参考

static string CreateSession(string connectionString)
{
    string strSessionID = "";
    AdomdConnection objConnection = new AdomdConnection();
    try
    {
        /*First, try to connect to the specified data source.
          If the connection string is not valid, or if the specified
          provider does not support sessions, an exception is thrown. */
        objConnection.ConnectionString = connectionString;
        objConnection.Open(); 
        // Now that the connection is open, retrieve the new
        // active session ID.
        strSessionID = objConnection.SessionID;
        // Close the connection, but leave the session open.
        objConnection.Close(false);
        return strSessionID;
    }
    finally
    {
        objConnection = null;
    }
}


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3