0
我有一個多維數據集,我試圖使用以下代碼檢索數據。我不知道列和行的查詢數將會返回。 我只想讀取每一列上每列的值。使用ADOMD從SSAS多維數據集獲取數據XMLReader
void OutputDataWithXML()
{
//Open a connection to the local server.
AdomdConnection conn = new AdomdConnection("Data Source=localhost");
conn.Open();
//Create a command to retrieve the data.
AdomdCommand cmd = new AdomdCommand(@"WITH MEMBER [Measures].[FreightCostPerOrder] AS
[Measures].[Reseller Freight Cost]/[Measures].[Reseller Order Quantity],
FORMAT_STRING = 'Currency'
SELECT [Geography].[Geography].[Country].&[United States].Children ON ROWS,
[Date].[Calendar].[Calendar Year] ON COLUMNS
FROM [Adventure Works]
WHERE [Measures].[FreightCostPerOrder]", conn);
//Execute the command, retrieving an XmlReader.
System.Xml.XmlReader reader = cmd.ExecuteXmlReader();
**// How to get the values form each column here ????
// I just want to read value of each column going over each row**
Console.WriteLine(reader.ReadOuterXml());
//Close the reader, then the connection
reader.Close();
conn.Close();
//Await user input.
Console.ReadLine();
}
以下鏈接說,從SSAS多維數據集檢索數據的最快方法是XMLReader的
http://msdn.microsoft.com/en-us/library/ms123479(v=sql.105).aspx
「處於斷開狀態檢索數據」您複製此[MSDN文章]這個代碼(http://msdn.microsoft.com/en-us /library/ms123462.aspx)。你有沒有設置數據庫? 'reader.ReadOuterXml()'返回什麼? – 2013-04-09 03:43:08
我想知道如何檢索數據,在這種情況下,你不知道有多少列查詢將返回。 – SharpCoder 2014-06-25 08:31:03
是的,**那麼reader.ReadOuterXml()返回什麼?** – 2014-06-26 00:48:48