65.9K
CodeProject is changing. Read more.
Home

ADOMD.NET DataAdapter / DataReader replacement

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.36/5 (6 votes)

Oct 4, 2005

1 min read

viewsIcon

52132

downloadIcon

779

This code replaces the buggy ADOMD.NET DataAdapter and DataReader.

Introduction

This code replaces the exceptionally buggy ADOMD.NET DataReader and DataAdapter classes.

Background

I am writing reports in ActiveReports for .NET and am currently porting a large set of reports to Analysis Services and MDX. In the process, I started out using the ADOMD data provider through the ADO data adapter. I discovered that this interface has a bug where you cannot query properties of parent-child dimensions. This was reported to MS and after 2 months of trying to get them to confirm it, they finally confirmed that it was a bug and they have no plans to fix it. This bug also appears in ADOMD.NET. After discovering that you also cannot query intrinsic properties of the measures dimension, I decided that I needed to write my own data provider. I started out using the ADOMD.NET Cellset as the data source, but that has a bug where it will crash on certain queries with a DuplicateNameException (reported to MS, no response yet). I then switched to using ADOMD through COM interop. All of the classes except MyMdDataReader are simple shells and not very interesting. Most of the functionality is enclosed in the MyMdDataReader.

Using the code

This is a direct drop-in replacement for ADOMD.NET if you need to use a DataReader or fill a DataSet from an MDX expression. Just replace references to AdomdDataReader, AdomdDataAdapter, AdomdConnection and AdomdCommand with MyMdDataReader, MyMdDataAdapter, MyMdConnection, and MyMdCommand respectively.

As far as I have tested this, it works with all MDX queries and will return the same column names as the AdomdDataReader. In addition it will return queried parent-child dimension properties, and the following intrinsic properties for all dimensions on the Y axis; CAPTION, CHILD_COUNT, LEVEL_DEPTH, LEVEL_NAME, NAME, UNIQUE_NAME.