This is a migrated thread and some comments may be shown as answers.

CubeDataSource SelectCommand Exception

3 Answers 94 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Wang
Top achievements
Rank 1
Wang asked on 27 Dec 2011, 04:00 AM
Hello,
    I am using the Telerik.Reporting.5.0.11.510 at the moment.
    
    Why I can't catch the command exception used the SelectCommand property of the CubeDataSource ? 
    
    Furthermore,I don't know How the CubeDataSource SelectCommand excute the mdx statement ? 

    Excuse me,How can I catch the command exception when the mdx statement has some exception ?

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 28 Dec 2011, 04:56 PM
Hi,

In general, our declarative data source components are intended to specify declaratively how to retrieve the data for the report. They do not contain any data at all, they only specify the means how to obtain it (e.g. in the case of SqlDataSource - by executing a SQL query against a database, or in the case of CubeDataSource - by executing an MDX query against OLAP cube, etc.). You can view the CubeDataSource component as wrapper and any exceptions you get would be coming straight from Analysis Server and displayed in the report. You can use the report error handling to catch the exception and change it if needed, but you would not be able to correct the problem, so your scenario is a bit unclear.

All the best,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Wang
Top achievements
Rank 1
answered on 29 Dec 2011, 06:44 AM
Hello Steve,
     Thanks for your response.

      I made a test by using the report error handling when the mdx query has some exception.
      but I can't still catch the CubeDataSource SelectCommand executive exception against OLAP cube.

      Please see this code below:
     
private void AlarmFloodDetailsReport_ItemDataBinding(object sender, EventArgs e) 
      {    
            try
                
                    cubeAlmFldDes = new CubeDataSource(); 
                    cubeAlmFldDes.ConnectionString = cubeConn; 
                    cubeAlmFldDes.SelectCommand = @"select non empty {[Measures].[AlarmCount]} on columns 
non empty  
nonempty([Date].[Date].[Date].members* 
[Time].[Hour].[Hour].members*[Time].[MinParent].[MinParent].members 
,{[Measures].[AlarmCount]}) 
on rows  
from [AAM4DW]"; 
                    rptCurrent.DataSource = cubeAlmFldDes; 
    
                    #region Table 
                    this.tabFldAlmDets.DataSource = cubeAlmFldDes; 
                    #endregion 
                
                catch(Exception ex) 
                
                    this.txtMsg.Value = ex.Message; 
                
      }
private void AlarmFloodDetailsReport_Error(object sender, ErrorEventArgs eventArgs)
        {
            this.txtMsg.Value = eventArgs.Exception.Message;
        }

Run project and show report, The report will display that information.Please see the attachment. 

Debug project and show report, I find the report error handling have not catch the command exception in time.

I am in urgent need of your help.Thanks

0
Steve
Telerik team
answered on 03 Jan 2012, 04:06 PM
Hello Wang,

As noted in our previous post, if your query is wrong, there would be no way to correct it inside report events, use SQL Server Management Studio to test/run your queries prior using them as data source for the reports.

On a side note, using ItemDataBinding event for binding the report is wrong, you should use NeedDataSource event instead. And instead of creating CubeDataSource Component inside the event (which is meant for design time binding), you can move your data retrieval code in a method and assign the result of this method as DataSource for the report directly or utilize ObjectDataSource Component to bind to that method through the designer.

In addition, the Error event handler would not return an error, because you're already handling it in the try-catch block.

Regards,
Steve
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Wang
Top achievements
Rank 1
Answers by
Steve
Telerik team
Wang
Top achievements
Rank 1
Share this question
or