Search code examples
crystal-reportsdatasetcrystal-reports-xi

Create Report using Crystal Report XI from DataSet


*STEP 1.*My program get Crystal Report (XI sp6) templates from admin. It parses the templates to get SQLs from that and then populate it to get DataTables for each SQL.
*STEP 2.*After that, it push the DataTables back into the ReportDocument to create the report by using the following code:

// there no subreport in our template
//mainDS include all populated DataTable having the same name of related CR Command Alias
foreach (Table tab in doc.Database.Tables)
    tab.SetDataSource(mainDS.Tables[tab.Name]);

The problem is (I wonder if it is a Crystal Report Bug): if there is 2 Command in the template, when the code tab.SetDataSource(mainDS.Tables[tab.Name]); is executed for doc.Database.Tables[0] then doc.Database.Tables[1].Fields is become the same to doc.Database.Tables[0].Fields and ofcause I get an error.

I do not get this error with all templates, just some :(. All templates worked well in Crystal Report GUI!!!

Please help if it not bug or please show me how to work around!

I am using Crystal Report XI Developer Edition with latest pack, VS2005. Oracle 10g, Devart DotConnect for Oracle Free version.


Solution

  • After mining SAP document and test many times, I think that it is a bug of CR XI R2 sp6. So I on report I only keep 1 Command, If there is a need for other commands, I will create subreports and put the commands in these.