我有一个MDX查询:
with member [Measures].[Error Measure] as 1/[Measures].[Non Existing]
select [Measures].[Error Measure] on 0 from [MyCube]
其中[Measures]。[不存在]在MyCube中不存在。
如果我尝试在SSMS中执行此查询,我将收到一个包含一个单元格的cellSet,内容将是#error(以及工具提示中的显式消息)。
另一方面,如果我创建一个AdomdCommand并使用:
执行此查询var adapter = new AdomdDataAdapter(command.CommandText, connection);
var ds = new DataSet();
adapter.Fill(ds);
我不会收到异常,我的数据集将加载一个带有一个唯一列的唯一行,内容将为null。我已经调查了GetColumnError()方法但没有指定任何内容。
有没有办法知道这个单元格是错误的而不是null(没有更改为cellSet)?
答案 0 :(得分: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]