Analysis Management Objects (AMO) 是SQL Server SSAS的对象模型库,通过它可以方便的对SSAS里的对象进行访问及控制,包括Cube,DataSource, DataSourceView, Partition, Measure, Dimension, Assembly, Role以及DataMining对象等。要使用它,必须在机器上找

Analysis Management Objects (AMO) 是SQL Server SSAS的对象模型库,通过它可以方便的对SSAS里的对象进行访问及控制,包括Cube,DataSource, DataSourceView, Partition, Measure, Dimension, Assembly, Role以及DataMining对象等。要使用它,必须在机器上找到SSAS的安装路径MicrosoftSQL Server90SDKAssemblies,把目录中的Microsoft.AnalysisServices.Dll文件加载到项目的Reference列表中,AMO对象就是通过这个Dll文件进行访问的。

首先要添加引用using Microsoft.AnalysisServices;

以下是测试用C#从SSAS中获取部分信息的源码:(代码中已经包含了较多的解释)

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Microsoft.AnalysisServices;

namespace AMOTest

{

class Program

{

static void Main(string[] args)

{

string ConnecteString = "Data Source =ServerName; Provider=msolap";

Server SSASServer = new Server();

SSASServer.Connect(ConnecteString);

List OutDatabase = GetDatabaseCollection(SSASServer);

//show all database on the server

Console.WriteLine("-------------Databse-------------------------------");

for (int i = 0; i < OutDatabase.Count; i++)

{

Console.WriteLine(OutDatabase[i].Name.ToString());

}

//show the Cube of a database

Console.WriteLine("---------------Cube--------------------------------");

List OutCube = GetCubeCollection(OutDatabase[0]);

for (int i = 0; i < OutCube.Count; i++)

{

Console.WriteLine(OutCube[i].Name.ToString());

}

//show all Roles of one database

Console.WriteLine("---------------Roles_database-------------------------");

List OutRole = GetRolescollection(OutDatabase[0]);

Console.WriteLine(OutRole[0].Members.Count);

//for (int i = 0; i < OutRole[0].Members.Count; i++) //to show the detial of the role Members

//{

// Console.WriteLine(OutRole[0].Members[i].Name);

//}

//show all Roles of one cube

Console.WriteLine("---------------Roles_Cube----------------------------");

List OutRole2 = GetRolescollection2(OutCube[0]);

Console.WriteLine(OutRole2[0].Members.Count);

//for (int i = 0; i < OutRole2[0].Members.Count; i++)

//{

// Console.WriteLine(OutRole2[0].Members[i].Name); //to show the detial of the role Members

//}

Console.Read();

}

//get the list of the database name

static public List GetDatabaseCollection(Server server)

{

List collectdb = new List();

foreach (Database db in server.Databases)

{

collectdb.Add(db);

}

return collectdb;

}

//get the list of a database cube name

static public List GetCubeCollection(Database db)

{

List collectcube = new List();

foreach (Cube cube in db.Cubes)

{

collectcube.Add(cube);

}

return collectcube;

}

//get the list of the database roles

static public List GetRolescollection(Database db)

{

List collectRoles = new List();

foreach (Role cp in db.Roles)

{

collectRoles.Add(cp);

}

return collectRoles;

}

//get the list of the cube Roles

static public List GetRolescollection2(Cube cube)

{

List collectionRoles = new List();

foreach (CubePermission cp in cube.CubePermissions)

{

collectionRoles.Add(cp.Role);

}

return collectionRoles;

}

}

}

这里需要说明的是,,当我获取Database的Roles和Cube的Roles值时,做了一个对比,他们的值是相同的。这可能的情况是,在Database中Cube只有一个,或者因为Cube隶属于database,他们的Roles值是相同的。

如下是运行完的截图:

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

ssas从mysql获取数据库_通过AMO获取SQL Server SSAS信息相关推荐

  1. 通过AMO获取SQL Server SSAS信息(C#)

    Analysis Management Objects (AMO) 是SQL Server SSAS的对象模型库,通过它可以方便的对SSAS里的对象进行访问及控制,包括Cube,DataSource, ...

  2. mysql和sql server能共存吗_让防火墙与SQL Server数据库共存

    欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 安全与性能是数据库管理员的两块心头肉.而通过防火墙来保护数据库的安全无疑是一种不错的选择.但是有时会防火墙与SQL S ...

  3. sql备份恢复数据库_使用DBATools通过SQL恢复数据库操作验证备份

    sql备份恢复数据库 In this article, we will explore database backup validation by with SQL restore database ...

  4. 数据库原理与应用(SQL Server)笔记 第二章 简单数据查询

    文章目录 前言 一.SELECT 子句 (一)投影指定的列和投影全部列 (二)AS子句修改查询结构的列标题 例题1 (三)TOP谓词限制结果集中的行数 (四)INTO子句将结果插入新表中 例题2 (五 ...

  5. mssql 数据库审计账户_SQLServer数据库审计功能入门之SQL Server审核 (SQL Server Audit)...

    本文主要向大家介绍了SQLServer数据库审计功能入门之SQL Server审核,通过具体的内容向大家展现,希望对大家学习SQLServer数据库有所帮助. 介绍 Audit是SQL Server ...

  6. JDBC连接SQL Server数据库[windows验证模式连接+SQL server验证]

    JDBC连接SQL Server数据库[windows验证模式连接+SQL server验证] 都说用JDBC连接数据库会出现很多问题,现总结.汇总一下. 前提是已经正确安装了SQL Server系列 ...

  7. 数据库原理与应用(SQL Server)笔记 第七章 流程控制语句、系统内置函数

    目录 一.流程控制语句 (一)BEGIN...END语句块 (二)条件语句 (三)循环语句 1.WHILE语句 2.BREAK语句和CONTINUE语句 (四)无条件转移语句 (五)返回语句 (六)等 ...

  8. 数据库原理与应用(SQL Server)笔记 第八章 用户自定义数据类型与变量

    前言 以下皆使用T-SQL语句的方式来执行语句,使用图形界面方式不再累赘. 一.用户定义数据类型 (一) CREATE TYPE 语句 1.CREATE TYPE语句 下面介绍使用T-SQL语句,创建 ...

  9. 数据库原理与应用(SQL Server)笔记 第一章 数据定义语言和数据操纵语言

    文章目录 前言 一.基本介绍 二.在SQL里执行T-SQL语句 三.数据定义语言(DDL) (一)概述 (二)数据定义语言用于数据库 1.创建数据库 2.修改数据库 3.使用数据库 4.删除数据库 5 ...

最新文章

  1. python计算多次_Python – 只计算一次属性并多次使用结果(不同的方法)
  2. NOIP信息奥赛--1995“同创杯”初中复赛题题解(三)
  3. 基于JAVA+SpringMVC+Mybatis+MYSQL的实验室设备管理系统
  4. 为什么开发人员应该学习 Kubernetes?
  5. 高等院校计算机考试等级,全国高等院校计算机等级试考试大纲.doc
  6. 使用ggplot2绘制心形
  7. 【LeetCode】【数组】题号:*661,图片平滑器
  8. GIS数据处理-OSGB转换3dTiles
  9. python英文文本词性分析
  10. 8051单片机实现与GSM通讯
  11. 网站漏洞修复公司 对网站上传文件漏洞的修复与安全加固
  12. position: relative相对定位 ; absolute绝对定位 子绝父相 盒子居中 堆叠顺序z-index cursor光标 hover悬停 轮播图 固定定位fixed
  13. Matlab之classification learner app无法从workspace导入label (response variable)
  14. 万彩办公大师多页PDF文档去掉空白部分合并到同一页
  15. ENQUEUE_MIGRATED
  16. WS2812原理及实现
  17. 优麒麟的一些使用上的问题
  18. 破除对于XP半开连接数限制的误解
  19. 用java创建person类_创建一个Person类,有以下属性:名字、身高、性别、年龄,创建10个对象,用java程序...
  20. 解决Eclipse中无法直接使用sun.misc.BASE64Encoder及sun.misc.BASE64Decoder的问题

热门文章

  1. ArcGIS案例学习笔记2_2_等高线生成DEM和三维景观动画
  2. MariaDB之SQL语句基础
  3. jieba分词单例模式及linux权限不够情况下tmp_dir自定义
  4. 【arc068F】Solitaire
  5. linux 安装jdk tomcat mysql
  6. XidianOJ 1090 爬树的V8
  7. 滚动文字Marquee属性及参数设置
  8. 使用HttpsUrlConnedtion连接https地址时异常处理 (方式二)
  9. Enterprise Continuous Integration with Binary Dependencies example
  10. 对抗学习新进展:MIT和微软联合出品“元对抗扰动”