我们如何使用 C# 代码通过 ASP.Net 处理多维数据集或访问 OLAP 数据库?在 C#.Net 中用于连接 OLAP 数据库或在分析服务中处理操作的组件是什么?
最佳答案
对于处理,使用 Microsoft.AnalysisServices 库,示例代码如下:
Server server = new Server();
server.Connect(cubeConnectionString);
Database database = server.Databases.FindByName(databaseName);
Cube cube = database.Cubes.FindByName(cubeName);
cube.Process(ProcessType.ProcessFull);
对于查询,使用 Microsoft.AnalysisServices.AdomdClient 库,示例代码如下:
using (Adomd.AdomdConnection adomdConnection = new Microsoft.AnalysisServices.AdomdClient.AdomdConnection())
{
adomdConnection.ConnectionString = cubeConnectionString;
Adomd.AdomdCommand adomdCommand = new Microsoft.AnalysisServices.AdomdClient.AdomdCommand();
adomdCommand.Connection = adomdConnection;
adomdCommand.CommandText = mdxQuery;
adomdConnection.Open();
cellSet = adomdCommand.ExecuteCellSet();
adomdConnection.Close();
}
请注意,这两个命名空间重叠,因此如果您在同一个地方使用它们,则可能需要别名。
http://msdn.microsoft.com/en-US/library/ms124924(v=SQL.90).aspx
http://msdn.microsoft.com/en-us/library/ms123483(v=SQL.90).aspx
关于c# - 处理立方体的组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2779077/