Skip to Content
0
Former Member
Jul 03, 2009 at 03:34 PM

Create Crystal Report at runtime

64 Views

I'm using the developer version of CR 2008 and trying to convert some BO Enterprise XI R2 managed RAS code that creates a report completely at runtime. In the code below I'm instantiating without error but when I assign the DataTable on the last line I get this error message:

The document has not been opened.

This is understandable as I have not invoked the Open() method. The problem is that the the Open() method requires a document path and this is a new document.

ReportClientDocumentClass oReportClientDocument;

SqlDatabase oSqlDatabase = new SqlDatabase(@"Data Source=SETON-DESKTOP\SQLEXPRESS;Initial catalog=Northwind;Integrated security=SSPI;Persist security info=False");

DataTable oDT;

oReportClientDocument = new ReportClientDocumentClass();

using (DbCommand oDbCommand = oSqlDatabase.GetStoredProcCommand("spc_SalesOrders"))

{

oDT = oSqlDatabase.ExecuteDataSet(oDbCommand).Tables[0];

}

oReportClientDocument.DatabaseController.SetDataSource(oDT, string.Empty, string.Empty);

In my original code I used the NewDocument() method of the ReportAppFactory to create the empty report object using the RAS but I'm working now with unmanaged code using only CR 2008.

Once I get the report instaltiated, the process of adding data fields, formula fields, sections, groups, and setting properties, etc. looks like its the same.

What am I missing?

Thanks

Carl