AdomDataRader returns the same value

93 Views Asked by At

Im developing a dashboard in ASP.NET whit a Cube in SQLServer.

Im trying to get the dimensions values to put into a ListBox.

When I execute the query, it returns the righ rows size, but the values are the same in eachone.

This is my code:

MDXQuery = @" WITH MEMBER [Measures].[Label] AS [Dim Career].[Dim Career Name Area].CURRENTMEMBER.MEMBER_CAPTION MEMBER [Measures].[UniqueName] AS [Dim Career].[Dim Career Name Area].CURRENTMEMBER.UNIQUENAME SELECT {[Measures].[Label], [Measures].[UniqueName] } ON COLUMNS , [Dim Career].[Dim Career Name Area].ALLMEMBERS ON ROWS FROM [DWH UNIT]";

         using (AdomdConnection cnn = new AdomdConnection(ConfigurationManager.ConnectionStrings["CuboCnx"].ConnectionString))
        {
            using (AdomdCommand cmd = new AdomdCommand(MDXQuery, cnn))
            {
                cnn.Open();
                using (AdomdDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (dr.Read())
                    {

                        select.NameCareer = dr.GetString(0);
                        select.ValueCareer = dr.GetString(1);

                        lstSelect.Add(select);
                    }
                    dr.Close();
                }
            }
        }

And I get this, after parsing to JSON the List:

[{ "NameCareer ": "TICS", "ValueCareer": "[Dim Career].[Dim Career Name Area].&[Programmer]" }, { "NameCareer ": "TICS", "ValueCareer": "[Dim Career].[Dim Career Name Area].&[Programmer]" }, { "NameCareer ": "TICS", "ValueCareer": "[Dim Career].[Dim Career Name Area].&[Programmer]" }, { "NameCareer ": "TICS", "ValueCareer": "[Dim Career].[Dim Career Name Area].&[Programmer]" }]

1

There are 1 best solutions below

0
On

I solve It, was a really dumb mistake.

I was instancing my object out of the while bucle.

Once I put the instance into the while, the problem has gone.

Thank you everybody!