Question

I've a MDX query:

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

where [Measures].[Non Existing] doesn't exist in MyCube.

If I try to execute this query in SSMS, I'll receive a cellSet with one cell and the content will be #error (and an explicit message in the tooltip).

On the other hand, if I create an AdomdCommand and execute this query with:

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

I'll not receive an exception and my dataset will be loaded with a unique row with one unique column and the content will be null. I've investigated the GetColumnError() method but nothing is specified.

Is there a way to know that this cell is in error and not null (without changing to a cellSet)?

Était-ce utile?

La solution

I do not know a solution for AdomdCommands, but within MDX: You can use the IsError method which actually is not an MDX, but a VBA method:

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]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top