Click here to Skip to main content
11,805,604 members (54,454 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Windows Application
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 3:11am
Edited 4-Nov-12 3:13am
GanesanSenthilvel at 4-Nov-12 9:14am
Code is highlighted
nkkppp at 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 at 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 at 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 at 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 at 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 at 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
0 OriginalGriff 310
1 Richard Deeming 225
2 Sergey Alexandrovich Kryukov 170
3 Abhinav S 128
4 ppolymorphe 125
0 OriginalGriff 3,300
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 4 Nov 2012
Copyright © CodeProject, 1999-2015
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