Click here to Skip to main content
Rate this: bad
good
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 18:52pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi
 
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
  Permalink  
Comments
Kuldeep B at 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"); //dt1.Clear(); //da.Fill(dt1); 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"); RptDoc.SetDataSource(ds1); SqlDataAdapter da1 = q.fillcurrentsale(); da1.Fill(ds2, "saletable"); //dt2.Clear(); //da.Fill(dt2); q.disconnect(); //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]; subRepDoc.SetDataSource(ds2); } } //Assign report to the crystal report viewer billp.crystalReportViewer1.ReportSource = RptDoc; // billp.crystalReportViewer1.DataBind(); }
@AmitGajjar at 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 at 12-Dec-12 3:27am
   
Main report print only Column Name ....Not print data....Only columns are display
@AmitGajjar at 12-Dec-12 3:40am
   
is your datasource correct have data ?
Kuldeep B at 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 at 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 at 12-Dec-12 3:59am
   
Yes Ankit It show Data In Main report When I disable Subreport.
@AmitGajjar at 12-Dec-12 4:03am
   
check http://www.dotnetspider.com/resources/43691-How-create-sub-reports-crystal-report.aspx link, you may missed something.
Kuldeep B at 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 at 12-Dec-12 4:09am
   
BTW my name is Amit :)
@AmitGajjar at 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
good
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[^]
  Permalink  

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

  Print Answers RSS
0 Dnyaneshwar@Pune 1,310
1 Sergey Alexandrovich Kryukov 726
2 Tadit Dash 345
3 OriginalGriff 313
4 Manas Bhardwaj 215
0 Sergey Alexandrovich Kryukov 11,700
1 OriginalGriff 6,980
2 Peter Leow 4,915
3 Abhinav S 3,838
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid