2013-07-24 109 views
1

我有一个MDX查询#ERROR(和not null):如何获得使用DataAdapter /数据集

with member [Measures].[Error Measure] as 1/[Measures].[Non Existing] 
select [Measures].[Error Measure] on 0 from [MyCube] 

其中[措施] [不存在的]不存在MyCube。

如果我试图在SSMS中执行这个查询,我会收到一个单元格的cellSet,内容将是#error(并在工具提示中显式消息)。

在另一方面,如果我创建一个AdomdCommand和执行这个查询有:

var adapter = new AdomdDataAdapter(command.CommandText, connection); 
var ds = new DataSet(); 
adapter.Fill(ds); 

我不会收到异常和我的数据集将被装入一个唯一行与一个唯一的列和内容将为空。我调查了GetColumnError()方法,但没有指定。

有没有办法知道该小区是错误的,并不能为空(不更改到单元集)?

回答

2

我不知道AdomdCommand个解决方案,但内MDX:您可以使用IsError方法这实际上不是一个MDX,但VBA方法:

with member [Measures].[Error Measure] as 1/[Measures].[Non Existing] 
    member [Measures].[Error Indicator] as IIf(IsError([Measures].[Error Measure]), 'error', 'ok') 
    member [Measures].[Error or Orig] as IIf(IsError([Measures].[Error Measure]), 'error', [Measures].[Error Measure]) 
select { [Measures].[Error Measure], [Measures].[Error Indicator], [Measures].[Error or Orig] } on 0 
from [MyCube] 
+0

好了,不出我所料(我我一直在寻找一些有用的东西,我认为不可能知道该列出现adomdCommand错误),但可能会使用您的VBA解决方案 –