/* * Execute custom query */ private void InitDataTable(string sQuery) { SQLMiningManager objMiningManager = new SQLMiningManager(); // clear node table GridViewDistribution.DataSource = null; GridViewDistribution.DataBind(); // display results Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetMiningResults(sQuery); if (objMiningData == null) { return; } DataTable objTable = new DataTable(); DataColumn myColumn = new DataColumn(); DataRow myRow = null; DataTable objSchemaTable = objMiningData.GetSchemaTable(); List <string> lMeta = new List <string>(); // init meta values for (int i = 0; i < objSchemaTable.Rows.Count; i++) { lMeta.Add(objSchemaTable.Rows[i][0].ToString()); } // add columns and column captions for (int i = 0; i < objMiningData.FieldCount; i++) { myColumn = new DataColumn(lMeta[i]); objTable.Columns.Add(myColumn); } // output the rows in the DataReader while (objMiningData.Read()) { // new row myRow = objTable.NewRow(); // set the row values for (int i = 0; i < objMiningData.FieldCount; i++) { myRow[i] = objMiningData[i]; } // add row to the table objTable.Rows.Add(myRow); } // close reader objMiningData.Close(); GridViewResults.DataSource = objTable; GridViewResults.DataBind(); // load the main table data Session.Add("queryMining", objTable); }
/* * Show distribution node for selected row */ private void DisplayDistributionNode(string sNodeName) { SQLMiningManager objMiningManager = new SQLMiningManager(); string sQuery = "select NODE_DISTRIBUTION from [" + DropDownListStructures.SelectedItem.ToString() + "].CONTENT where NODE_NAME ='" + sNodeName + "'"; // display results Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objMiningData = objMiningManager.GetMiningResults(sQuery); // return for invalid data if (objMiningData == null) { return; } Microsoft.AnalysisServices.AdomdClient.AdomdDataReader objNode = null; // output the rows in the DataReader while (objMiningData.Read()) { for (int j = 0; j < objMiningData.FieldCount; j++) { objNode = (Microsoft.AnalysisServices.AdomdClient.AdomdDataReader)objMiningData[j]; // table defines DataTable objTable = new DataTable(); DataColumn myColumn = new DataColumn(); DataRow myRow = null; // Get the node meta DataTable objSchemaTable = objNode.GetSchemaTable(); List <string> lMeta = new List <string>(); // init meta values for (int i = 0; i < objSchemaTable.Rows.Count; i++) { lMeta.Add(objSchemaTable.Rows[i][0].ToString()); } // add columns and column captions for (int i = 0; i < objNode.FieldCount; i++) { myColumn = new DataColumn(lMeta[i]); objTable.Columns.Add(myColumn); } // read the node while (objNode.Read()) { // new row myRow = objTable.NewRow(); // set the row values for (int i = 0; i < objNode.FieldCount; i++) { myRow[i] = objNode[i]; } // add row to the table objTable.Rows.Add(myRow); } // close reader objNode.Close(); GridViewDistribution.DataSource = objTable; GridViewDistribution.DataBind(); // hide viewer panel and show grid table GridViewDistribution.Visible = true; PanelViewer.Visible = false; // load the main table data Session.Add("queryNode", objTable); } } // close reader objMiningData.Close(); }