1471477 - Using the RAS SDK for VS .NET, how to determine number of data rows returned to a report?

SAP Knowledge Base Article - Public

1471477 - Using the RAS SDK for VS .NET, how to determine number of data rows returned to a report?

Symptom

Need to suppress printing of report if no data is returned

Resolution

Use the following code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportAppServer.ClientDoc;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.DataDefModel;
namespace ras115_get_row_count
 
{
 
 public partial class Form1 : Form
 
{
 
public Form1()
 
{
 
 InitializeComponent();
 
}
 
private void button1_Click(object sender, EventArgs e)
 
{
 
 ReportDocument boReportDocument = new ReportDocument();
  ISCDReportClientDocument boReportClientDocument = null;
  RowsetController boRowsetController;
  RowsetCursor boRowsetCursor;
 
 int rows;
 
 boReportDocument.Load(Application.StartupPath + "\\..\\..\\CrystalReport1.rpt");
  boReportDocument.Refresh();
 boReportClientDocument = boReportDocument.ReportClientDocument;
 boRowsetController = boReportClientDocument.RowsetController;
 boRowsetCursor = boRowsetController.CreateCursor(new GroupPath(), new RowsetMetaData(), 0);
 
 rows = boRowsetCursor.RecordCount;
 
 MessageBox.Show(rows.ToString());
 
 boReportDocument.Close();
}
 
}
 
}

Keywords

Forum Thread , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2