Click here to Skip to main content
11,706,728 members (33,670 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VS2008 C# SQL CrystalReports , +

I want to set data source dynamically to a Crystal Report in C# Winform application..
But when I create the crystal report with "Using the Report Wizard", it shows all records fields in crystal report..

I checked the SQL Query in Crystal Report -> Right click on "Database Fields" in Field Explorer and then click on "Show SQL Query..."
It show simple connection, which fetch all records from two tables..

How to set that SQL Query dynamically???

I tried to set dataset, when I call the Crystal report, but it does not worked... Frown | :-(
My C# code is :-
OleDbConnection con = new OleDbConnection("Provider=Microsoft.jet.oledb.4.0; data source=" + Application.StartupPath + @"\DataInfo1.mdb;Persist Security Info=true;User Id='Admin'; password=;");
OleDbDataAdapter da = new OleDbDataAdapter(@"SELECT ct.custID, c.custName, c.custAdd,ct.custTranDate,ct.custTranType,ct.custPaidAmt,ct.custDueAmt, c.custArea FROM custTransaction ct left JOIN custDetails c ON ct.custID = c.custID where ct.custID='CUST-000002' and ct.custTranDate BETWEEN #2/28/13# AND #3/1/13#", con);  
DataSet ds = new DataSet();
CrystalReport1 cr = new CrystalReport1();
this.crystalReportViewer1.ReportSource = new CrystalReport1();
Please help me.

Thanks in Advanced.
Posted 6-Mar-13 4:38am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

u r problem is over here
this.crystalReportViewer1.ReportSource = new CrystalReport1();
u have to use as follows
this.crystalReportViewer1.ReportSource = cr;
hope it will help
also check following link...[^]
Jayanta Chatterjee at 6-Mar-13 11:16am
Thankss a Lottttttttt Sir...

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

  Print Answers RSS
0 OriginalGriff 146
1 Sergey Alexandrovich Kryukov 140
2 chainerlt 110
3 Mika Wendelius 80
4 ppolymorphe 71
0 OriginalGriff 9,190
1 Sergey Alexandrovich Kryukov 8,407
2 CPallini 5,189
3 Maciej Los 4,756
4 Mika Wendelius 3,686

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 6 Mar 2013
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