Crystal Report Sub Report Problems

Hello,
I am unable to use subreports within Crystal.
I call my data from a MySQL connection string, read it into a data set and then display the fields from the datasets within a report. I can do this fine for 1 report, but when I try to include a subreport it does not work.
I have tried lots of diffeent methods but have been unabled to get it working. I have tried the merge tool btw.
Help would be amazing please....
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Web
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim con As MySqlConnection
Dim myData, myLookUpData As New DataSet
Dim cmd, cmdLookUpData As New MySqlCommand
Dim myAdapter, myAdapterLookUpData As New MySqlDataAdapter
Dim myReport As New ReportDocument
Dim selectProperty As String
con = New MySqlConnection()
selectProperty = "pra50191"
' selectProperty = InputBox("Enter a Property Reference")
'Connection String
con.ConnectionString = ("Server=*****.ukservers.net;Database==****.;UID==****.;Password==*****.")
Try
con.Open()
cmd.CommandText = "SELECT a.no_name, a.address_line1, a.address_line2, a.address_line3,a.address_line4, a.town, a.county, a.postcode, a.display_price, a.general_desc, a.ref, a.viewing_text, a.directions, a.services, b.dimensions_ft, b.dimensions_m, b.description, b.fk_property_ref, b.fk_lookup_rootyp_id FROM tblproperty a, tblproperty_room_details b WHERE a.ref = b.fk_property_ref AND a.ref= '" & selectProperty & "'"
cmdLookUpData.CommandText = "SELECT id, description FROM tbllookup_user"
cmd.Connection = con 'Sets the SQLCommand to the connection string
cmdLookUpData.Connection = con
myAdapter.SelectCommand = cmd 'Sets the MySQL dataadapter to the command (connection string)
myAdapterLookUpData.SelectCommand = cmdLookUpData
myAdapter.Fill(myData) 'Fills the data table
myAdapterLookUpData.Fill(myLookUpData)
myReport.Load("C:\Users\zac\Documents\PJC Report\pjcBrochure2\brochure2\brochure2\testV2.rpt") 'Loads the report (report file location)
myReport.SetDataSource(myData)
myReport.SetDataSource(myLookUpData)
myReport.Database.Tables(0).SetDataSource(myData.Tables(0)) 'Add the tables to the report
myReport.Database.Tables(1).SetDataSource(myLookUpData.Tables(0))
CrystalReportViewer1.ReportSource = myReport 'Loads report into the viewer '
Catch myerror As MySqlException
MsgBox(myerror.Message) 'Error msg if the connection is unable
End Try
End Sub
End Class

I moved your post to the .NET - SAP Crystal Reports forum.
You are not passing anything to the subreport. I htink as it is, you're kinda hoping that somehow the subreport will know what dataset it is supposed to use. There is a couple of ways you can call the subreport and than pass the dataset to it. If you know the name of the subreport:
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument
crSubreportDocument = crSubreportObject.OpenSubreport("XXX")
crSubreportDocument.SetDataSource(myLookUpData)
or if you do not know the name of the subreport (a more extensible way I suppose you can loop through all the sections of the report looking for the subreport;
Dim crSections As Sections
Dim crSection As Section
Dim crSubreportObject As SubreportObject
'set the crSections object to the current report's sections
crSections = crReportDocument.ReportDefinition.Sections
'loop through all the sections to find all the report objects
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
'you will need to typecast the reportobject to a subreport
'object once you find it
crSubreportObject = CType(crReportObject, SubreportObject)
'open the subreport object
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
'set the database and tables objects to work with the subreport
<your .SetDataSource code here>
Next
End If
Next
In all of this, don't forget to consult your developer help file. Looking at the samples [here|https://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples] will also be a good idea.
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup
Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Similar Messages

  • Crystal report - sub report

    Hi everyone
    Can anybody help me with crystal report - sub report problem  as i am new to crystal report.
    I have created two reports"mainreport" and "subreport" using crysta report XI with the same query for both reports using stored procedure. I set the links for both reports at design time and its works fine there. then i added those two reports into my .net application and now i want to set the paramaters and also want to set the datasource  programatically with same query but with two different functions which returns datatable. I am using .visual studio 2008 (.net 3.5) and sql 2005 as back end.
    Any help will be appreciated.
    Thanks In Advance
    Regards,
    Shruti Batra

    Only CR 2008 (12.x) and CR 10.5 (bundles with .NET 2008) is supported with .NET 2008. And while running reports created in CR XI with CR 10.5 may work, you are taking your chances with parameterized reports as there have been a lot of changes in the parameter behavior between CR 10 and CR XI. Thus, my recommendation would be to upgrade to CR 2008, ensuring your version is 12.3.0.601.
    Re. programming questions. Start with sample apps:
    https://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsfor.NETSDK+Samples
    See the [Crystal Reports For Visual Studio 2005 Walkthroughs|https://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/2081b4d9-6864-2b10-f49d-918baefc7a23&overridelayout=true]. It will apply to CR 2008 and VS 2008.
    See the developer help files;
    https://boc.sdn.sap.com/developer/library
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup

  • Regarding Crystal report Sub Report.

    hi.
    i have one requirement About sub report.
    I have done customization...tables Document types.
    header Document
    rows    Documentrow1
    rows    Documentrows2
    one header and Two child tables i have created object and data also there.
    in Details section i put
    from Documentrows1 table
    line1
    line2
    lined3
    line4
    this is fine..
    but
    from Documentrows2  tabel i want to put
    line1
    line2
    line3
    linet4
    at Report footer.
    at end of the report only......
    Is it possible.
    i put one sub report.
    but if i click only it is opening new preview and then it is showing.
    line1
    line2
    line3
    only
    how can solve this one
    i need in single preview only....
    I need your Valuable suggestions..

    Dear Srininvas,
    You have to link Main report and subreport....
    In the navigation pane..Edit->subreport links..
    Rgards
    Ajith

  • Reports & Sub-Report

    I am new to oracle reports and would like to know how to design
    sub-reports.
    I have a main query that I need to run. For each record in that
    main query, I would like to run 2 others queries where the key
    is equal to the key in the main query.
    Is this possible?? Any help is appreciated...
    Jarett
    [email protected]

    Create separate links in the data model, each links the main
    query to separate sub query based the key. In the layout you
    need to manually place the repeating frame of the sub queries
    WITHIN the repeating frame of the main query.
    Read the help file in Report Builder if you need to know how to
    create the link.

  • Sub report using Stored Procedure returns incorrect data

    Post Author: rikleo2001
    CA Forum: Data Connectivity and SQL
    Guys,
    I am using CR 9 in ASP.net application.
    One simple report and one Sub report, sub report is basically linked with Stored procedure accepting one parameter and returns a select query.
    Main report is linked with that sub report using that parameter field.
    Sub report is on demand sub report.
    Now when I execute that main report and click on on demand sub report I am getting Wrong order information.
    Here is out put on main report
    Order 1                                          on demandDetail
    Order 2                                          on demandDetail
    Order 3                                          on demandDetail  
         NOW If I click on Order 3 (On demanddetail link, it displays rondom order details, some time correct on too), I am really stuck and don't know where I am going wrong.
    Please help me to solve this issues.
    Many Thanks

    Post Author: rikleo2001
    CA Forum: Data Connectivity and SQL
    Hi Yangster,
    Thank you so much for your reply.
    On DEMAND Sub report is located in main report, IN DETAIL SECTION
    I am passing Order ID from main report linked to  {?morderid} in subreport under command object, and if I run it in design mode, it works perfectly alright, so problem is isolated to ASP.NET and Crystal report post back method on Crystal report.
    The example I give to you this is a simple example to identify issues in my real application and report.
    My main report contains summary of data base on unique identifier. that summary have 4 differant types of details which has to be on the same report (as Crystal report doesn't provide Nested subreport), so I decided to use 4 subreports on main report and all subreport using Stored procedure command object.(Sub report has it own complex processing requirement to fulfill).
    Please help me with any further ideas? for the sample which I presented to you this is only using one SP on main report with a simple processing.
    Many Thanks

  • Display different footer in main report of SSRS based on sub report

    I have a main report in which there are two sub reports and then those two sub reports each contain one sub-subreport.
    The following will give you an idea
    Main Report
    ----->Sub Report 1
    ------------>Sub Sub Report 1
    ----->Sub Report 2
    ------------>Sub Sub Report 1
    I am trying to display name of subreport in footer of main report depending on which subreport user is currently in. So let's say if user is viewing Sub Report 1 then it should display in footer of main report "Sub Report 1" (this is actually coming
    from database and is not like displaying some static text but for the time being ignore this)  
    If user is viewing Sub Sub Report 1 then footer of main report should say "Sub Report 1: Sub Sub Report 1"  
    After searching a bit I found out that:
    1. Sub report footer will not be shown in Main report hence this option is ruled out
    2. You cannot pass parameter from sub report to main report so this option is also ruled out
    But looks like you can use Shared Variables between Sub Report and Main Report. I tried to do this but looks like it doesn't work. Here's what I did:
    In my Sub Report 1, I declared a shared variable as below:
    Public Shared Dim sharedVariable as String = "Sub Report 1"
    Now in my Main Report I wrote the following function in code just to test if it prints it on screen on not.
    Public Function PrintSharedVariable() as String
    Return sharedVariable
    End Function
    But when I run this report, it shows error that sharedVariable is not declared in Main Report. How do I use shared variables and will it work in my case?

    Hi Frank,
    According to your description, you want to show the subreport name in the main report. Right?
    In Reporting Services, all the custom code is only work for the current report. The sharedVariable you created in subreport can't be used in main report. That's the reason why it throws the error because there's no sharedVariable in main report. For your
    requirement, the most effective workaround is having a textbox with go to report Action and passing the report name as parameter back to main report.
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • How to Avoid Printing the data twice when the sub report has drill down?

    Hello,
    I have a sub report that has drill down which is placed in report footer.When i run the report sub report displays the data but when i tried to drill down it displays the same data again.After that i can able to drill down on sub report.Is there any way to avoid
    printing the same data twice.
    Thanks in advance.

    Hi,
    If the subreport you're referring to does not grow in size and it does not span multiple pages and you know the size of it, here's what you can do to stop drilling into subreports :
    1) Create a text object as large as the subreport (perhaps bigger than it) and fill it with spaces or new lines
    2) Place it 'over' the subreport such that it covers the entire area occupied by the subreport
    3) The subreport at all times should be smaller than the text object in all dimensions
    Now, when you hover the mouse over the subreport, there isn't any magnifying glass for you to drill down into.
    If the subreport has further drill-down functionality, then this isn't for you! Because, it just wouldn't allow you click on any objects in the subreport because of the text object eclipsing it. This is the only workaround I know at this point in time and I know a lot of users are looking for this.
    I would suggest that you log this as an Enhancement Request at http://ideas.sap.com for our developers to have a look into this.
    And finally, I also found an old forum post where Jamie has suggested a way to get this working on the Business Objects Environment. Give it a shot, if that's where the reports are eventually run.
    How to disable subreport view
    Hope this helps!
    -Abhilash

  • Sub Report Performance problem

    Our current software configuration is Microsoft SQL Server 2008 R2 (10.0.2531.0) where our data is housed. Our User Interface is Microsoft Visual Studio 2008 (Visual Basic) and Microsoft .NET 3.5 SP1 platform.  We use Crystal Reports 2008 (12.0.0.683) to do our reporting.
    We upgraded from Crystal Reports XI and our reports are taking a long time to render?... Is there any evidence of other companies experiencing this trouble? Are there any degraded performance issues when moving from XI to 2008?
    In some cases we utilizing a small simple sub report.
    Any help appreciated. Thanks.

    Hi Billy,
    Subreports in detail sections are never a good idea. Example, you have 100 records returned int he main report and if that field is your subreport link it causes the subreport to run 100 times. Your database is being queried 101 times.
    Also, the default time out for database is typically 1 minute, could be you need to verify your report and database so CR can "clean up" any wrong pointers.
    It's always better to do the data collection server side if and when possible, after all that's what they do best.
    Not much detail to go on so I can't say if it's a report design problem other than the above or not. It could be also that .NET takes time to load all of the CR assemblies so depending on how you have your app configured depends on the delay. If you load a dummy report when your starts up to pre-load CR runtime then subsequent reports will be much faster.
    Also check off all of the Verify Database options, you may be telling CR to verify each time which on big databases can cause a delay also.
    Thank you
    Don

  • Sub report parameter prompt appears when running Visual Studio 2008 with Crystal Reports 2008

    Post Author: relliott
    CA Forum: .NET
    If I build a simple Crystal Report that contains another simple Crystal Sub Report, the report will print preview fine in Crystal 2008.  The problem happens when add this report to a Visual Studio 2008 Web Application Project and I build and debug the application, the Crystal Viewer is prompting the user for the parameter used to link the sub report to the main report.  This should never happen as the user is not supposed to see this parameter.  If I type in some value for this sub-report parameter prompt, the Crystal Report Viewer gives an error message about not finding the field.
    I was having the same problem in Vs2005 with Crystal 10 which is why I upgraded.  Business Object's official fix for this problem was published under their KB article number c2018840 and c2019047.  These hot fixes ended up causing general exception errors in Visual Studio so I scrapped these solutions.
    Support had me install SP0 for Crystal 2008 (which did not fix it).
    Any ideas?
    Any help is greatly appreciated.
    Thanks,
    Rich Elliott

    Hi Bontrager,
    Thank you for posting in MSDN forum.
    According to your description, I agree with pvdg42's suggestion, so I suggest you can try pvdg42's suggestion to install the version of
    Crystal Reports 10.5 to check this issue again.
    Reference:
    http://forums.asp.net/t/1236730.aspx?Which+CR+version+is+in+Visual+Studio+2008+
    In addition, since this forum is
    to discuss: Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor. So if you have any issue about the
    Crystal Reports, I suggest you can ask the issue to the
    SAP Crystal Reports website:
    http://scn.sap.com/community/crystal-reports/content?filterID=contentstatus%5bpublished%5d~objecttype~objecttype%255bthread
    as pvdg42 pervious suggestion, it will be better support.
    Thanks for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Crystal Report Viewer - Sub Reports

    Hi Everyone,
                        I'm working with Crystal Reports(V13.0.7) Windows form viewer in VS2012(VB.Net). I have a sub report which is causing problems. I have set the link to the Main report parameter and Sub report. I have a total of 43 parameters getting passed(Main and Sub Reports including). While setting the ReportSource in code, I find that there are 43 parameter fields passed. But i constantly get an error "The parameter is incorrect". An important thing to note is that- Whenever i debug the code, the report gets displayed but it is not so when in release mode. Can anyone help me in this regard. I'm totally frustrated and its been weeks and i haven't solved the issue yet. I have attached the files below (FrmViewer - Used to add and set report source for Main and sub reports) and (Display-AR-REPORT( ) - for passing main report and sub report parameters). The AR.Rpt report

    Hi Sastry,
                   Firstly, thanks for replying to my post. I have checked all the parameters passed, did some changes(Had extra 0's after decimal point), but still no change. The same old Error. As i have mentioned before, Whenever i debug the code, the report gets displayed but it is not so when in release mode. The file (Original Report.png)image is a Perfect report. The report file (MyReport.png)shown below is my report.

  • Sub report group tree in main report Using crystal report 12

    Hi experts,
        I have a strange requirement like, same data needs to be grouped two different ways in a same report.  Like
    Store1:
        Summary of sales on each item chart
    Store2:
        Summary of sales on each item chart
    .....it goes like this
    Department1(multiple stores)
          summary of sale on each item chart - store1
          summary of sale on each item chart - store2
         --........ it goes
    Department2
          summary of sale on each item chart - store3
    --........ it goes
       Its in single report, the first part is grouped only with store and in second part the store is under department. How to do this in same report?
        I achieved  this by creating a sub report to display the first part of data and in the main report sup report data plus the second part of data will be displayed. And its working well but now the problem is the group tree, I'm not able to see the sub report group tree in the main report.
       How to get the sub report group tree in the main report, Or is there any other better way is there so i can get both the data as well the group tree. Please help me to solve this. CryCryCry
    I'm using crystal report 2008(installed separately) with Visual Studio2008 (.Net3.5)
    Thanks in advance.

    Hi
    Thanks for the reply.
        Yea both data source are same(Datasource is SQL Stored Procedure). I cant use like that, because my client needs the group tree also. In case if there is no group tree, we can create one more group and supress it conditionaly. But here the problem is there is no way to suppress any of the group item in group tree as we can do it in the detail section.
        So please me with some different ways and also , please clarrify the following doubts
    1. Can we supress one or more items in the group tree.
    2. Can we get the sub report group tree in main report(Everything is working when i used the sub reports except the group tree). So I'm trying for different ways to do, but none is helping me
    Please help me

  • Report containing 15 sub reports crashing - Crystal Reports 2008

    I am using Crystal report 2008 with all latest service packs applied. I have more then 20 different reports wich work absolutely fine and never crash. One of my report contains 15 sub reports since its bringing data from 15 different queries. This consistently keeps crashing everytime I try to run it. Not sure what could be the root cause.
    We are using Postgres database and connected to it with  ODBC connection using Microsoft DSN.
    - All Subreport data is being displayed on Report Footer
    - All subreports are included in the Main report  page header section. (I have also tried doing it on report footer section but it still crashes)
    I have tried searching through the forum and did not find similar issue resolutions. Did someone face similar problems before?
    The crash message is:
    "crw32.exe has encountered a problem and needs to close. We are sorry of the inconvenience."
    Error report contains this data:
    AppName: crw32.exe      AppVer: 12.2.0.290      ModName: psqlodbc35w.dll
    ModVer: 9.0.2.0      Offset: 0004c538
    I am using Windows XP
    Crystal Report Version Details:
    CR Developer Version 12.2.0.290
    Product Type: Full
    Let me know how can I debug this issue? Any help is appreciated.

    @Don - We performed extensive testing for this crash issue and found that now this crash is not happening only in one scenario. So we have partially fixed this.
    Now the report crashes if I get disconnected from database and reconnect. This is what happens
    1. open the report in crystal report 2008
    2. try to run the report when db is connected- it works fine.
    3. Now disconnect the database (we are using ssh tunnel to connect to db so we just close the tunnel)
    4. now try to refresh the report - it fails to retrieve data.
    5. Now close the report without saving it.
    6. Now Close Crystal Report.
    7. Now Connect the DB using ssh tunnel so crystal report can connect.
    8. Now open Crystal Report
    9. Launch the target report.
    10 Preview the report - it works for first time.
    11. Now do a refresh keeping same parameters - Report crashes here.
    - I tried these steps with some of my other reports and they do not crash.
    - Now I have only one report which contains a Postgres Query with date range,order by and a union join.
    - No subreports now - I am trying to run this one subreport as a standalone report which I created from scratch(using blank report wizard) and just copied the query.
    Any more pointers would help.

  • Sub reports In Crystal reports XML as a data Source

    Hi,
    I am facing one problem related to Sub reports functionality in crystal reports as XML as a data Source. We are using CrystalReports XI for this.
    I was generated PDF's using crystal reports from ruby on rails, by using the JAVA API to produce the PDF by taking the XML,XSD,and RPT files as parameters. I  succeed in this case
    and the way we are communicating with JAVA API using  from my Ruby on Rails application by the following link.
    http://rorataspire.wordpress.com/2008/06/13/how-to-integrate-crystal-reports-with-ruby-on-rails/
    Right Now my problem is as follows.
    The problem with the sub reports generation from  crystal reports.  We had one main report file(RPT), In that we are using the Sub reports,for that sub reports need to parse the XML's and XSD's dynamically based on the report encountered on the main(RPT)file,but to send more than one XSD's and XML's dynamically  based on the  sub report, to the JAVA API from Ruby on Rails application I am not succeeded.  So as a result  PDF with the Dynamic data for Sub reports is not fulfill.
    Your help is appreciable, Thanks in advance.

    Is this a coding question or a data source format question?
    Sincerely,
    Ted Ueda

  • Crystal runs sql command of first sub report in the second sub report ?

    Hi,
    I have report that contains 3 sub reports.
    Each subreport is running his own sql command to retrieve it's data.
    When moving from the first subreport to the 2nd subreport, we see on the oracle that the crystal runs the sql command of the 1st subreport, and then the sql command of the 2nd subreport.
    The results are fine (he ignores the 1st subreport result in the 2nd subreport), but it delays the showing of the 2nd subreport to show.
    Why? The 2nd subreport doesn't need the data of the 1st subreport!
    How do I cancel that????
    BTW - The 3rd subreport is running only his own sql command (As should be).
    Thanks.

    Hello,
    Not without more info about the report and the data. If there is nothing linked from the main report to sub1 then it's going to run and return all data, no filtering. And from the sounds of it to take 5 + minutes per query this is going to affect performance for the whole report.
    You may want to re-evaluate why and what the subreports are used for. If they all use the same data the link them in the main report use groups to sort the data.
    Having subreports in the Details section is asking for performance problems, every record returned will cause the subreport to run. Not knowing what the subs are doing I can't say for sure....
    What you should do also is re-evaluate your Commands for each sub and see if you can do it either in one SQL statement or write a Stored Procedure to do all of the data collection. DB Servers are much more efficient at collecting data than CR will ever be. Pushing just the results to CR makes it simply formatting the results in the Designer and no performance hits....
    Talk to your DBA on how to optimize your Command SQL's and how to get them into one SQL or into a SP that dumps the final results into a final SQL * from TEMP Table into Crystal.
    Don

  • Crystal report(Can i link sub report and main report Compulsorily) - invalid path

    hi.
    i need small clarification.
    i am developing one Crystal report
    main report i took it from rdr1 one table...
    report is working fine..
    Sub report i took it from inv1 one table.
    i have not linked any fields from these tables.
    May be it is having links in b1..
    but in my other report both the tables.... from main report  and sub report does not have any relation.
    My Questions is..
    Can i Compulsorily link fields to main report...
    if both does not have any relation what should i do...
    i took two tables.
    main report rdr1
    sub report inv1...
    if i  run the report it is asking two parameters one is for sub report and other one for main report working find in crystal report.
    but...i want to run the report in b1.
    while importing i am getting the error (Plz have a look on below image)
    if i choose any other report it is importing  fine...
    Clearly i am mentioning i dont want to link both tables there is no links between two reports...
    in this scenario can develop  a report..
    I need your Valuable suggestions.
    here below u can find my developed sample report...
    http://www.megafileupload.com/en/file/544758/NewReport-rpt.html

    hi.
    If i try only i am getting the error..
    out side if i run i am able to run the crystal report but
    in b1 i am not able to import the report.
    you can also try my report
    from below link u can get my simple report.
    if u find any mistake what i have done plz inform me..
    http://megafileupload.com/en/file/544806/NewReport85-rpt.html

Maybe you are looking for