Click here to Skip to main content
13,348,514 members (80,699 online)
Rate this:
Please Sign up or sign in to vote.
I am developing a windows application using C# Vs2008 . I need to create dynamic crystal report.
To create the dynamic crystal report, first I add a dataset and then a datatable to the dataset. Now I add 4 columns to the datatable.
Now I add a crystal report and bind the crystal report with the datatable of the dataset. Now I take a crystalreportviewer and bind the crystalreport with the crystal reportviewer. The following code i used..

private void button1_Click(object sender, EventArgs e)
         CrystalReport1 objRpt = new CrystalReport1();
         SqlCommand cmd=new SqlCommand("select pro_id,pro_nm,quantity,total from bill_t ",con);
         SqlDataAdapter da=new SqlDataAdapter(cmd);
         DataSet1 ds = new DataSet1();
         da.Fill(ds, "bill_t");
         crystalReportViewer1.ReportSource = objRpt;

I did not get any error, only crystal report does not show anything.
So, Please help me to solve this problem.
Posted 4-Nov-12 4:11am
Updated 4-Nov-12 4:13am
GanesanSenthilvel 4-Nov-12 9:14am
Code is highlighted
nkkppp 4-Nov-12 9:54am
Hi Dude,

I think you need to change the code to

objRpt.SetDataSource(ds.Table[0]); as you are referring to table at index 0

manabjn 4-Nov-12 10:06am
I did it, but it display only the column names of the datatable of the Dataset dataset1 .
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

manabjn 4-Nov-12 14:39pm
crystalReportViewer1.ReportSource = objRpt;
//objRpt is the object of Crystal report...
I dont know where is the fault.
Either on first line or second line must have the fault. Dataset fill with data but i dont khow what to do now.. Plz help me
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

manabjn 4-Nov-12 14:16pm
I follow the all steps whatever you mentioned, but still it remain unchanged............
anyway thank for your kind help
Khalid Farhan 5-Nov-12 5:10am
Would you give detail...What is happening? Use debugging to get is there report file & data getting or not.
manabjn 5-Nov-12 10:41am
whenever I debug my project ,dataset is loaded with new table bill_t with my required data. Thus at runtime , dataset DataSet1 has two table, one is DataTable1(which is created at designing time of Dataset1) and other one is bill_t. Upto this everything is seems to be right.
crystalReportViewer1.ReportSource = objRpt;//where obj is the object the Crystal report CrystalReport1
I think above two line of codes have some mistake..
Please Help me

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 |
Web02 | 2.8.180111.1 | Last Updated 4 Nov 2012
Copyright © CodeProject, 1999-2018
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