Click here to Skip to main content
15,936,169 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to generate a report dynamically by using C#. Currently Im getting the values to a dataSet. Now I need to set that DataSet as the data source to my report. How can I do this.

Im using crystal reports at the moment... But Its not working
DataSet ds = dba.genarateReport2(cmbJobCat.SelectedValue.ToString(),cmbSubCat.SelectedValue.ToString());
CrystalReport1 cr = new CrystalReport1();
crystalReportViewer1.ReportSource = cr;

My SQL query is this
"select * from itpJobs J,itpJobCategory C, itpJobSubCategory S 
J.jobCategory = C.jobCatId and J.jobSubCategory = S.jobSubCatid 
and C.jobCatId=" + jc + "and S.jobSubCatid=" + jsc + ""
Updated 8-Aug-12 7:57am
Kschuler 8-Aug-12 14:03pm    
What do you mean "it's not working"? Is it causing an error? If so, what error are you getting? Or is it just not showing anything in the report?
Thilina C 8-Aug-12 14:06pm    
Yes, It's not showing any thing in the report. When I manually set the database fields , It's displaying some values. But not according to my sql query

1 solution

Please, read these articles:

On the first look, your query should looks like:
FROM itpJobs AS J LEFT JOIN itpJobCategory AS C ON J.jobCategory = C.jobCatId LEFT JOIN itpJobSubCategory AS S ON J.jobSubCategory = S.jobSubCatid 
WHERE C.jobCatId=" + jc + " AND S.jobSubCatid=" + jsc + ""
Share this answer
Thilina C 8-Aug-12 22:07pm    
ok but still the problem is there. :(
Maciej Los 9-Aug-12 16:30pm    
What kind of problem? Show me a realationships between tables, example data.

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900