利用Adomd 执行Cube 数据库的配置。
需要 下载: Microsoft.AnalysisServices.AdomdClient , 安装,再搜索到DLL的位置,在程序里引用
环境: Sql Server 2022 表格模型
脚本内容存放在: s01.json文件里
AdomdConnection conn = new AdomdConnection("Data Source=localhost"); conn.Open(); string json = System.IO.File.ReadAllText("s01.json"); AdomdCommand cmd = conn.CreateCommand(); cmd.CommandText = json; int result = cmd.ExecuteNonQuery(); conn.Close(); Console.WriteLine("press enter to exit."); Console.ReadLine();
说明: json脚本可以在SSMS里 属性里生成脚本得到
1. 更改数据连列和密码的json
{ "alter": { "object": { "database": "Cube2024", "dataSource": "dw" }, "dataSource": { "type": "structured", "name": "dw", "connectionDetails": { "protocol": "tds", "address": { "server": "192.168.1.241", "database": "dw" }, "authentication": null, "query": null }, "credential": { "AuthenticationKind": "UsernamePassword", "Username": "dev", "Password": "Password", "EncryptConnection": false } } } }
2. 配置role及用户
{ "createOrReplace": { "object": { "database": "Cube2024", "role": "Role" }, "role": { "name": "Role", "description": "这是一个测试role", "modelPermission": "read", "members": [ { "memberName": "dev" } ] } } }
3. 处理数据
{ "refresh": { "type": "automatic", "objects": [ { "database": "cube2024" } ] } }
标签:Cube,自定义,database,Adomd,json,role,dw,conn From: https://www.cnblogs.com/easybi/p/17987185