The function getDataTable() is based on the code found here (translated into C#): http://asmdx.blogspot.com/2008_05_01_archive.html
The GridView is just a simple GridView: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns=true></asp:GridView>
The result of the query I'm testing with should be in 5 columns. All of the information is displayed, but the first three columns are crammed into one.
Description
Score
Opponent Score
1988-09-03AL
6
7
1988-09-10AL
12
32
1988-09-17HL
16
27
...And so on. Those two letters after the date should each be in their own column. Also, the first column is always "Description". This comes from the implementation of the code, and I can't figure out how to make that first column dependent on the query
instead of what is hard coded.
I was also trying another method to bind the data:
AdomdConnection conn = new AdomdConnection("connection string");
conn.Open();
AdomdCommand cmd = new AdomdCommand("MDX query");
This time, it displays the first three columns correctly (the three that the first method crammed into one column), but does not display the last two columns at all. This method is also inferior because instead of displaying nice column names it displays
part of the query.
Do these three good columns have something to do with the three columns displayed in the design view? Where are these columns coming from and how can I get more of them?
Alternatively, is there an easier way to display this data that I'm missing?
I think the problem may be that the column names for these three columns are the same. getDataTable probably tries to make a single column out of them. You may want to make sure they have distinct column names.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
How did you design your Columns of the GridView?
If you confirm that you really have five columns in the DataTable, please set
the property of Gridview "AutoGeneratedColumn=true" and have a try.
Harabeck
0 Points
1 Post
Trouble displaying results of MDX query in GridView
Nov 18, 2010 10:24 PM|LINK
I'm a novice trying to display the results of an MDX query. The following code is in the Page_Load:
AdomdCommand objCommand;
CellSet objCellSet;
string sConnString;
string strCommand;
AdomdConnection objConnection;
strCommand = "valid mdx query";
sConnString="valid connection string";
objConnection = new AdomdConnection(sConnString);
objConnection.Open();
objCommand = new AdomdCommand(strCommand, objConnection);
objCellSet = objCommand.ExecuteCellSet();
GridView1.DataSource = getDataTable(objCellSet);
GridView1.DataBind();
objConnection.Close();
The function getDataTable() is based on the code found here (translated into C#): http://asmdx.blogspot.com/2008_05_01_archive.html
The GridView is just a simple GridView: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns=true></asp:GridView>
The result of the query I'm testing with should be in 5 columns. All of the information is displayed, but the first three columns are crammed into one.
...And so on. Those two letters after the date should each be in their own column. Also, the first column is always "Description". This comes from the implementation of the code, and I can't figure out how to make that first column dependent on the query instead of what is hard coded.
I was also trying another method to bind the data:
AdomdConnection conn = new AdomdConnection("connection string");
conn.Open();
AdomdCommand cmd = new AdomdCommand("MDX query");
DataTable dt = new DataTable();
AdomdDataAdapter myDataAdapter =new AdomdDataAdapter(cmd);
myDataAdapter.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
This time, it displays the first three columns correctly (the three that the first method crammed into one column), but does not display the last two columns at all. This method is also inferior because instead of displaying nice column names it displays part of the query.
Do these three good columns have something to do with the three columns displayed in the design view? Where are these columns coming from and how can I get more of them?
Alternatively, is there an easier way to display this data that I'm missing?
</div> </div>GridView MDX
superguppie
All-Star
48225 Points
8679 Posts
Re: Trouble displaying results of MDX query in GridView
Nov 19, 2010 09:42 AM|LINK
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Trouble displaying results of MDX query in GridView
Nov 22, 2010 01:31 AM|LINK
How did you design your Columns of the GridView?
If you confirm that you really have five columns in the DataTable, please set
the property of Gridview "AutoGeneratedColumn=true" and have a try.