net.What I am trying to do is to execute an MDX query using ado.net in Visual studio 2015.Can somebody please refer me the link so that I would able to know how it works.
Apart from that, I need to ask apart from the community that is ado.net is the only way to execute MDX queries can't I do it using something else.I am using vb.net as a server side language.Please let me know any link or code which would help me.
There is a lot information in internet, like this or that .
C#:
using (AdomdConnection conn = new AdomdConnection("Data Source=tfsDB;Initial Catalog=Tfs_Analysis; MDX Compatibility=1;"))
{
conn.Open();
var mdxQuery = new StringBuilder();
mdxQuery.Append("WITH ");
mdxQuery.Append("SET [Last 4 weeks] as Filter([Date].[Date].[Date], [Date].[Date].CurrentMember.Member_Value < Now() AND [Date].[Date].CurrentMember.Member_Value >= DateAdd(\"d\", - 28, Now())) ");
mdxQuery.Append("SELECT NON EMPTY Hierarchize(AddCalculatedMembers({DrilldownLevel({[Work Item].[System_WorkItemType].[All]})})) DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS , NON EMPTY {Hierarchize(Distinct({[Last 4 weeks]}))} DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON ROWS ");
mdxQuery.Append("FROM (SELECT ({[Work Item].[System_WorkItemType].&[Requirement], [Work Item].[System_WorkItemType].&[Change Request]}) ");
mdxQuery.Append("ON COLUMNS FROM [Team System]) WHERE ([Work Item].[Iteration Hierarchy].[All],[Test Case].[System_WorkItemType].[All],[Work Item].[System_State].&[Active],[Measures].[Work Item Count]) ");
using (AdomdCommand cmd = new AdomdCommand(mdxQuery.ToString(), conn))
{
DataSet ds = new DataSet();
ds.EnforceConstraints = false;
ds.Tables.Add();
DataTable dt = ds.Tables[0];
dt.Load(cmd.ExecuteReader());
return dt;
}
}
Since I prefer to use Linux on server side, you may check my blog post about accessing cubes via Python.
Python:
>>> import olap.xmla.xmla as xmla
No handlers could be found for logger "olap.xmla.requests_kerberosauth"
>>> provider = xmla.XMLAProvider()
>>> connect = provider.connect(location='http://localhost/OLAP/msmdpump.dll',username='test_user',password='1234567')
>>> source = connect.getOLAPSource()
>>> print source.getCatalog("TestCube")
XMLACatalog:(row){
CATALOG_NAME = "TestCube"
DESCRIPTION = ""
DATE_MODIFIED = "2016-08-07T09:47:05.026667"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.