locked
Problem in Creating Crystal Report with mysql in C# RRS feed

  • Question

  • I want to make crystal report in windows application from multiple tables in mysql database but when i use this no any data shown on my report how i can troubleshoot this? Somebody help me Please....
    Friday, May 24, 2013 12:16 PM

Answers

All replies

  • Hi, Can u elaborate in what control u r binding the Crystal report.? Did you caught any exception...?
    Friday, May 24, 2013 1:03 PM
  • Hey this is me....

    I bind the data by the MySqlDataAdapter to the tables of dataset. And there is no any exceptions thrown by the Program. 

    • Edited by Binit7777 Saturday, May 25, 2013 9:03 AM
    Saturday, May 25, 2013 9:02 AM
  • As you didn't show any relevant part of the respective code, we need to guess. I suspect from the little you told us so far, that your sql query does not deliver what it's supposed to deliver.

    To clarify this, you could debug your code by setting a breakpoint on an appropriate line right after your query is executed and see if you get any useful data.

    Kind regards,

    wizend

    Saturday, May 25, 2013 12:11 PM
  • I already do that in the debuging  process everything shows correct but in the result no anything display over the report.

    Now this is my Code

     //adapter to use sql commands...
                    MySqlDataAdapter adapter1 = new MySqlDataAdapter("Select Addmission_No,Date,Month,Student_Name,Class,Section,Roll_NO,Address,Fathers_Name,Development_Fee,Transport_Fee,Tutition_Fee,Hostal_Fee,Others,Misc,Examination_Fee,SchooBasedActivity, ScienceLabCharge, ComputerLabCharge,Total From Demand_Bill where Addmission_No='" + AdmNo + "'AND Month='" + month + "'", Connection.Connect_Main());
                    MySqlDataAdapter adapter2 = new MySqlDataAdapter("Select ID,School_Name,Established_Date,Address,Contact from Account_Details", Connection.Connect_Main());
                    MySqlDataAdapter adapter3 = new MySqlDataAdapter("Select Coalesce(Dues_Amount-Paid_Amount)as Total_Amount from Student_Account where Addmission_No='" + AdmNo + "'", Connection.Connect_Main());
                    //DataSet for Crystal report and fill data to datatable..
                    Demandbill smdata = new Demandbill();
                    adapter1.Fill(smdata, "Demand_Bill");
                    adapter2.Fill(smdata, "Account_Details");
                    adapter3.Fill(smdata, "Student_Account");
                    //call the .rpt file and set the datasource and display it
                    DemandReport demrep = new DemandReport();
                    demrep.SetDataSource(smdata);
                    crystalReportViewer1.ReportSource = demrep;

    Monday, May 27, 2013 5:42 AM
  • first create a very simple report having data from single source only. if that works then try your above code. Make sure sources name matches like ("Demand_Bill", Account_Details", "Student_Account").

    try the following link.

    http://www.codeproject.com/Articles/14029/How-to-Create-a-Crystal-Report-using-C-and-MySQL


    Faisal Ahmed Farooqui —————————— If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, May 27, 2013 7:28 AM
  • You've got three adapters, each containing one datatable to fill. Does neither of them receive any data, or do you see differences?

    In case of no data at all, you could verify if you've got an open connection. If the property 'State' of your MySqlConnection has the value 'ConnectionState.Closed', then check out your connection string.

    If there are differences between your datatables take a closer look at your Select clause.

    Monday, May 27, 2013 7:45 AM
  • I check it already in the debug process all datatables carry data into the debug process. But on the report there is nothing to display.

    It's creating problem with multiples tables only.

    It's working fine with single table.

    Monday, May 27, 2013 8:10 AM
  • Sir ,I already do it with single table it's working absolutely fine ...
    Monday, May 27, 2013 8:17 AM
  • Ok, that narrows it down.

    You have multiple datatables. So you need to set datasource to each table:
    demrep.Database.Tables[0].SetDataSource(smdata.Tables[0]);
    ...
    
    crystalReportViewer1.ReportSource = demrep;


    • Proposed as answer by Binit7777 Monday, May 27, 2013 11:08 AM
    Monday, May 27, 2013 8:28 AM
  • this is for the First table

    And for the second table

    I have to use

    demrep.Database.Tables[1].SetDataSource(smdata.Tables[1]);

    am I right?

    Monday, May 27, 2013 11:26 AM
  • Yes, that's what the "..." stand for.

    BTW, I'm not completely sure about the square brackets in 'Tables[]', maybe, it was round braces '()'? Just check it out!

    wizend

    Monday, May 27, 2013 12:05 PM
  • Tables[] is right but it shows only one table values next two is empty again....
    Monday, May 27, 2013 12:19 PM
  • I think, if you want to show the data of your tables in your report you 've to combine them first. On how to do that, there exist various proposals:

    http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-multiple-tables.htm

    http://www.codeproject.com/Questions/263183/multiple-tables-or-datasets-as-reportSource-in-cry

    They all have in common that you either need to combine the fields of your multitude of tables first and then pass them to your dataset or you need to use subreports.

    But to show multiple datatables independently in your DataReport is very problematic and object of many discussions (one for many: http://www.codeproject.com/Questions/445279/how-to-bind-crystal-report-from-multiple-datatable)

    • Marked as answer by Bob Shen Wednesday, June 5, 2013 6:52 AM
    Monday, May 27, 2013 1:14 PM