SSAS系列——【08】多维数据(程序展现Cube)

1、引用DLL?

      按照之前安装的MS SQLServer的步骤安装完成后,发现在新建的项目中“Add Reference”时居然找不到Microsoft.AnalysisServices.AdomdClient命名空间,不知道是什么状况?只好添加DLL了,在“C:\Program Files\Microsoft.NET\ADOMD.NET\100\Microsoft.AnalysisServices.AdomdClient.dll”下找到了该文件,该文件的最后修改时间是2009年3月30日,534KB。如图:

dll

图 AdomdClient.dll的磁盘路径

2、连接字符串?

本人觉得这一块和ADO.NET没有太大的区别,此处我使用的连接字符串是:Provider=SQLNCLI10.1;Data Source=localhost;Integrated Security=SSPI;Initial Catalog=BPDW; ,该字符串可以在数据源设计器中找到,所以根本无需记忆,会找即可。

ll

图 连接字符串

3、第一个程序

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   
string ReturnCommandUsingCellSet()
{
// Create a new string builder to store the results
System.
Text .StringBuilder result = new System. Text .StringBuilder();
// Connect to the local server
using (AdomdConnection conn
= new AdomdConnection("Provider = SQLNCLI10. 1 ;Data Source = localhost;Integrated Security = SSPI;Initial Catalog = BPDW;"))
{
conn.
Open ();
// Create a command, using this connection
AdomdCommand cmd
= conn.CreateCommand();
cmd.CommandText
= @" select { [ Measures ] . [ Oil Proved Reserves ] } on columns ,{ [ Dim Time ] . [ 年份 ] . & [ 19 ] } on rows from [ BPDW ] where [ Dim Geography ] . [ 国家名称 ] . & [ Total Asia Pacific ] & [ China ] ";
// Execute the query, returning a cellset
CellSet cs
= cmd.ExecuteCellSet();
// Output the column captions from the first axis
// Note that this procedure assumes a single member exists per column .
result.Append("\t");
TupleCollection tuplesOnColumns
= cs.Axes [ 0 ] . Set .Tuples;
foreach (Microsoft.AnalysisServices.AdomdClient.Tuple
column in tuplesOnColumns)
{
result.Append(
column .Members [ 0 ] .Caption + "\t");
}
result.AppendLine();
// Output the row captions from the second axis and cell data
// Note that this procedure assumes a two - dimensional cellset
TupleCollection tuplesOnRows
= cs.Axes [ 1 ] . Set .Tuples;
for ( int row = 0 ; row < tuplesOnRows. Count ; row ++ )
{
result.Append(tuplesOnRows
[ row ] .Members [ 0 ] .Caption + "\t");
for ( int col = 0 ; col < tuplesOnColumns. Count ; col ++ )
{
result.Append(cs.Cells
[ col, row ] .FormattedValue + "\t");
}
result.AppendLine();
}
conn.
Close ();
return result.ToString();
}
// using connection
}

 

转载于:https://www.cnblogs.com/caichen/archive/2010/07/13/1776434.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值