SAP Knowledge Base Article - Public

1663341 - How to add a database field to a Crystal Report using InProc RAS SDK


The following code will use Xtreme sample database to insert a field into an existing report:

private void AddTableFromDataSet(ref CrystalDecisions.CrystalReports.Engine.ReportDocument rpt, System.Data.DataSet ds)
ISCDReportClientDocument rasReport = rpt.ReportClientDocument;
// Convert the DataSet to an ISCRDataset object (something the ISCDReportClientDocument can understand)
CrystalDecisions.ReportAppServer.DataDefModel.ISCRDataSet rasDS;
rasDS = CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter.Convert(ds);

// Add the dataset as a data source to the report

// Add a field to the report canvas
// Note: This is quick and dirty. No positioning, resizing, formatting, etc.
CrystalDecisions.ReportAppServer.Controllers.ISCRResultFieldController rfc;
CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable crTable;
CrystalDecisions.ReportAppServer.DataDefModel.ISCRField crField;

rfc = rasReport.DataDefController.ResultFieldController;
crTable = rasReport.Database.Tables[0];
crField = crTable.DataFields[2]; // Hardcoded field "Customer Name" in the Customer table from Xtreme Sample Database
rfc.Add(-1, crField);

// Save the report template to disk (without data)
//object path = @"c:\documents and settings\administrator\desktop\";
//rasReport.SaveAs("test.rpt", ref path, 0);



  • Crystal Reports 2008 (12.x)
  • Crystal Reports for Visual Studio 2010
  • VS 2008
  • VS 2005
  • VS 2010

See Also



enter change CR2010 2010 CR4VS2010 CR4VS VS2010 NET2010 Crystal Reports for .NET Framework 4.0 crforvs 13 db data base , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To


Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio