Databases Reference
In-Depth Information
displaying a multidimensional data. And, the Microsoft FlexGrid —a native control for
displaying data in grid format—is no longer distributed with Visual Studio. Therefore, we
have published a sample Grid control to demonstrate the display of multidimensional
data. This Grid control is a legacy control, written in native code, that we use for demon-
stration purposes only. If you want to play around with it, you can download the sample
database, code samples, and other information from the web at http://www.samspublish-
ing.com or from http://www.e-tservice.com.
To place the results of an MDX query in a grid, follow these steps:
1. Create a new project in Visual Studio .NET. (See the “Creating an ADOMD.NET
Project” section earlier in this chapter.)
2. Right-click References in the tree view on the left, and then click Add Reference.
3. On the COM tab of the References dialog box, select the INView ActiveX Control
module.
4. Open Form1 in form design mode.
5. In the Toolbox, right-click Data and select Choose Items.
6. On the COM Components tab of the Choose Toolbox Items dialog box, select
INView Control.
7. Drag the grid to the form.
You have now created a toolbar with an Execute button and a text box for entering
query text.
When the user clicks the Execute button, a connection to the server is created, and the
query is executed. To simplify the sample, we support only queries that request two axes
from the server (see Listing 33.20).
LISTING 33.20
Displaying Multidimensional Data in a Grid
private void toolStripButtonExecute_Click(object sender, EventArgs e)
{
if (queryBox.Text.Length <= 0)
return;
try
{
//Open a connection to a server.
AdomdConnection con = new AdomdConnection(“Datasource=localhost;
Initial Catalog=Foodmart 2008;”);
con.Open();
AdomdCommand command = con.CreateCommand();
command.CommandText = queryBox.Text;
//Execute a command and get a cellset back.
CellSet cellset = command.ExecuteCellSet();
//Display the result in the grid.
DisplayResult(cellset);
Search WWH ::




Custom Search