【发布时间】:2013-04-09 03:30:18
【问题描述】:
我有一个多维数据集,我正在尝试使用以下代码检索数据。我不知道查询将返回的列数和行数。 我只想读取每一行的每一列的值。
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 article 复制了此代码。你设置好数据库了吗?
reader.ReadOuterXml()返回什么? -
我想知道在您不知道查询将返回多少列的情况下如何检索数据。
-
是的,那么 reader.ReadOuterXml() 返回什么?
标签: c# asp.net cube ssas-2008 adomd.net