cancel
Showing results for 
Search instead for 
Did you mean: 

Problems to assign datatable (from dataset) to subreport

Former Member
0 Kudos

Hi all.

I am having a lot of problems with all my reports that contains any subreport/s (only crashes in client´s machines, not development machine), Due this reports are a bit complex, ill try to make a new simple report with a subreport to see if it works but i had no results, and the problems is that i dont receive any message error, the program just crashes. I looked up for a solution and any of it works for me, The most common problem with subreports is that the sql query of the subreport and dataset are different, in my case are the same and the report its too simple to crash the application.

Here is the dataset that is assigned to the subreport:

Dim _dsld As DataSet = iCalc.SelectSql("select CR.pr_id,cr_id from corridas as cr inner join prestamos as pr on pr.pr_id=cr.pr_id where pr_nombre='" + CBOPrestamo.SelectedValue + "'")

                Dim rep_ As New CRPrueba

                rep_.Subreports("CRPruebaSub.rpt").SetDataSource(_dsld.Tables(0))

                rep_.SetParameterValue("pr_nombre", CBOPrestamo.SelectedValue)

             

                CrystalReportViewer1.ReportSource = rep_

Here is the subreport command:

select CR.pr_id,cr_id from corridas as cr inner join prestamos as pr on pr.pr_id=cr.pr_id where pr_nombre='{?pr_nombre}'

If i dont assign a dataset (datatable) to the subreport and insted of it i put the name of the loan, the subreport doesnt crashes, then the problem is at the moment of the dataset assignment to the subreport but i dont understand why crashes, in fact, i dont understand why reports that i dont made a change are crashing the application when it does not happened before.

I hope you can help me because if i can´t solve it,I'll have to make the reports without subreports (increasing the complexity of the reports)

Thanks in advance 

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

A bit of info missing:

Version of CR - please be precise

Version of VS .NET

Define "crash". Error? Behavior? Symptom?

I am also assuming that you are loading the main report - and you are not showing that code? E.g. the full code would be something like:

Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        crReportDocument.Load("C:\WindowsApplication5\test.rpt")


//loop through all the sections to find all the report objects
foreach (CrystalDecisions.CrystalReports.Engine.Section crSection in crSections)
{
    crReportObjects = crSection.ReportObjects;
    //loop through all the report objects to find all the subreports
    foreach (CrystalDecisions.CrystalReports.Engine.ReportObject crReportObject in crReportObjects)
    {
        if (crReportObject.Kind == ReportObjectKind.SubreportObject)
        {
            //you will need to typecast the reportobject to a subreport
            //object once you find it
            crSubreportObject = (CrystalDecisions.CrystalReports.Engine.SubreportObject)crReportObject;
            string mysubname = crSubreportObject.SubreportName.ToString();

            //open the subreport object
            crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);

            //set the database and tables objects to work with the subreport
           rep_.Subreports("CRPruebaSub.rpt").SetDataSource(_dsld.Tables(0));
            }
        }
    }
}

CrystalReportViewer1.ReportSource = crReportDocument

Couple of things to try:

1) Don't set the parameter - what happens now?

2) Save out the subreport and run it as it's own main report. What happens now?

Also see the sample apps csharp_win_subreport_basic.zip and csharp_win_subreport_logon.zip

  here:

Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki

Developer Help Files:

SAP
Crystal Reports .NET SDK Developer Guide

SAP
Crystal Reports .NET API Guide

- Ludek

 

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Version of CR: 13.0.4.705

Version of VS .NET: VS 1010 Ultimate


Define "crash". Error? Behavior? Symptom?: After press the button that show the report the application does not respond, just  appear a message box with a button and a label that says "the program has stoped and need to close", then I press the button and the aplication close, that´s all i can do.


The problem here is that in some times the reports runs just fine, but some times not, this can happen every time i compile the proyect and rune the new .exe file.


I will try your suggestions, for now i have another problems with the application and need to solve it first.


Thanks in advance and we keep in touch.


Former Member
0 Kudos

Was able to solve the problem and the solution was to modify the .exe.config file with this information:

<?xml version="1.0"?>

<configuration>

  <configSections>

  </configSections>

  <startup useLegacyV2RuntimeActivationPolicy="true">

    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

  </startup>

</configuration>

After save the file and replace it in clients machine all the report works fine.

Thank you very much and I hope my solution will be of help for another people.

former_member183750
Active Contributor
0 Kudos

Yup. Documented in this KBA, but I did not have enough info to suggest the solution...

- Ludek

Former Member
0 Kudos

I don´t knew what was the problem until the reports starting to fail in the developer machine (where I could see the description of the problem and that´s why I could solve it).

Thank you again.

former_member183750
Active Contributor
0 Kudos

Yup. Understood. That is why it is important to note the little details, like versions of cr / net and db used, connectivity type, etc., etc. Next time - but better if there is no next time

Happy coding,

- Ludek

Answers (0)