Click here to Skip to main content
12,624,895 members (36,891 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# CrystalReports
Hi Friends...
I'm doing one project that I need to create bill in crystal report.Like...

To : Customer Name................................Bill No: 100
Customer Address.....................................Date : 10/10/2012
Contact : 9850******
Particulars |Qty |Rate |Total |
Pen | 5|5|25
Notebook 5 | 20|100
Mobile Cover | 5|30|150

So How Can I create this Bill Because the problem is that..
1)Table1 Has only One row (Customer name,Address,Contact,Bill No,Date)
2)Table2 has more than two Rows.

Please Do needful......
Posted 10-Dec-12 19:52pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


there are many ways to achieve what you would like to do. one of the solution is, you can create one subreport for the detail section and associate different datasource to main report and sub report.

your main report may point to the header information and subreport will take your detail section information.

hope you can do this easily

best luck
Kuldeep B 12-Dec-12 3:14am
Anit :Thanks for Solution

I tried with your Idea but I'm getting only second table values in sub report.
And no any value in Main report....

Below is my code wht I tried:
SqlDataAdapter da = q.fillbill(bill);
da.Fill(ds1, "billtable");

if (dt.Rows.Count > 0)
//Assign data to the primary report
// CrystalReport1 RptDoc = new CrystalReport1();
ReportDocument RptDoc = new ReportDocument();
RptDoc.Load("C:\\Users\\Sunlogic\\Documents\\Visual Studio 2008\\Projects\\My Stock\\My Stock\\CrystalReport1.rpt");

SqlDataAdapter da1 = q.fillcurrentsale();
da1.Fill(ds2, "saletable");
//Get sub report and assign datatable1 to that report
foreach (ReportObject repOp in RptDoc.ReportDefinition.ReportObjects)
if (repOp.Kind == ReportObjectKind.SubreportObject)
string SubRepName = ((SubreportObject)repOp).SubreportName;
ReportDocument subRepDoc = RptDoc.Subreports[SubRepName];
//Assign report to the crystal report viewer
billp.crystalReportViewer1.ReportSource = RptDoc;
// billp.crystalReportViewer1.DataBind();

@AmitGajjar 12-Dec-12 3:16am
check if your main report print anything ? add one simple label and check if label is display there?
Kuldeep B 12-Dec-12 3:27am
Main report print only Column Name ....Not print data....Only columns are display
@AmitGajjar 12-Dec-12 3:40am
is your datasource correct have data ?
Kuldeep B 12-Dec-12 3:46am
ya... datasource has data....
I'm getting data from ds2 but not from ds1...Now problem is only with Main report...
...My assigning method is correct or any changes required...please go through code if u have free time...Please..
Thanks for giving time for me..
@AmitGajjar 12-Dec-12 3:48am
disable your subreport and check if your data display in main report. first just create simple report and once you got your header information in main report then add subreport.
Kuldeep B 12-Dec-12 3:59am
Yes Ankit It show Data In Main report When I disable Subreport.
@AmitGajjar 12-Dec-12 4:03am
check link, you may missed something.
Kuldeep B 12-Dec-12 4:08am
Amit Problem Is solved ..Now I'm getting data from both tables.
I Do what u say.
1)Delete Sub report
2)inserts fields from database fields in main report
3)Debug Project
4)Inserted sub Report
5)Double click on sub report ..In field explorer I right click on database fields ..then selected database expert ...And next steps are same..

Thank you very Much Amit:)
@AmitGajjar 12-Dec-12 4:09am
BTW my name is Amit :)
@AmitGajjar 12-Dec-12 4:13am
i suggest you not to publish your email address on public site, it will increase spam emails....
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Without more information about your project and what you are having trouble with...all I can suggest is that you probably want to put the Table1 customer data in the page or report header section and use the Table2 product data in your detail section.

It sounds like you might want to research about basic crystal reports first. Maybe do some sample project or tutorials first to get the hang of it.
You could start here:
Google results[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100