public ArrayList MDXquery(string strQuery, string connectionString, string txtUser, string txtPassword, string strCatalogName) { ArrayList al = new ArrayList(); string str = ""; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en-US"); //AdomdConnection conn = new AdomdConnection(connectionString + ";UID=" + txtUser + ";PWD=" + txtPassword + ";Catalog=" + strCatalogName); try { AdomdConnection conn = new AdomdConnection(connectionString + ";UID=" + txtUser + ";PWD=" + txtPassword); conn.Open(); AdomdCommand cmd = new AdomdCommand(strQuery, conn); CellSet cst = cmd.ExecuteCellSet(); str = ""; for (int i = 0; i < cst.Axes[1].Set.Tuples[0].Members.Count; i++) { if (i > 0) { str += "\t"; } Microsoft.AnalysisServices.AdomdClient.Member myMember = cst.Axes[1].Set.Tuples[0].Members[i]; string strMember = myMember.LevelName; strMember = strMember.Replace("[", "").Replace("]", ""); str += strMember; } for (int i = 0; i < cst.Axes[0].Set.Tuples.Count; i++) { for (int j = 0; j < cst.Axes[0].Set.Tuples[i].Members.Count; j++) { str += "\t" + cst.Axes[0].Set.Tuples[i].Members[j].Caption; } } al.Add(str); for (int j = 0; j < cst.Axes[1].Set.Tuples.Count; j++) { str = ""; for (int k = 0; k < cst.Axes[1].Set.Tuples[j].Members.Count; k++) { if (k > 0) { str += "\t"; } str += cst.Axes[1].Set.Tuples[j].Members[k].Caption; } for (int k = 0; k < cst.Axes[0].Set.Tuples.Count; k++) { str += "\t"; str += cst.Cells[k, j].Value; } al.Add(str); } conn.Close(); } catch (Exception e) { string errorMessage = e.Source + " " + e.Message; al.Add(errorMessage); //MessageBox.Show(e.Source + " " + e.Message); } return(al); }
public Member(AsAdomdClient.Member obj) { _obj = obj; }