Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
My database consist of 5 rows where each row consist of students register for subjects.
Following is my database design :
HTML
Name		|USN	|SubCode  |Test1  |Test2  |Sum	
StudentName 	 001	 Sub001	   27 	    35     62 
StudentName 	 001	 Sub002	   28 	    30     58
StudentName 	 001	 Sub003	   35 	    35     70
StudentName 	 001	 Sub004	   30 	    35     65
StudentName 	 001	 Sub005	   33 	    27     50   

From the above table, as studentname and USN is common, i just need an instance of those
data and I want Subcode, Test1, Test2 and Sum column to be displayed in a particular
section of crystal report in a datagrid view format. Is this possible?
Posted

1 solution

You can create a dataset (using dataset component in VS). Add that dataset to crystal report. In design mode for the report, drag and drop said data wherever you want.

Now all you have to do is create the instance of the report in code and pass it real dataset with your data.

You can easily find the details googling.
 
Share this answer
 
v3
Comments
partha143 19-Jun-15 11:43am    
Sinisa, thank you for your reply. I have already successfully implemented what you have suggested. My question is how can I pass a all contents of datatable/dataset/datagrid to a particular section in Crystal Report? I want to achieve this as I am developing marks card for my college where I am passing subjectcode,test1,test2 and sum to my report with either datatable/dataset/datagrid and I am passing respective Name and USN individually to the same report.
Sinisa Hajnal 19-Jun-15 15:11pm    
Well, dataset can contain multiple tables so you could pass it into report and use one part in group header, another in page header and yet third in details.

Or you could create subreport (this is the only way to have details of details item) - subreport behaves in all ways as normal report (has name, datasource, headers, details, other sections, etc) - it is simply embedded in the master report at some point.

Does that help?
partha143 20-Jun-15 1:04am    
Sinisa, could you please share any of the example code for the 1st solution you have provided in above comment (dataset can contain multiple tables so you could pass it into report and use one part in group header, another in page header and yet third in details.). I guess this solution will solve my problem. Thank you
Sinisa Hajnal 20-Jun-15 3:52am    
Unfortunately, I can't. This is not dependant on the code. You have to create a dataset in VS designer (you can simpy drag stored procedure from the datasource). You can find the description of the procedure online. However, very important thing is to NAME THE TABLES. Then before you assign the datasource in code, you name the tables in your dataset the same (case SENSITIVE).

When you create that datasource, open the report in designer and add that datasource component as datasource. You will see all the tables of that datasource available - it's just a matter of placing the data where you want it.

As it is designer based and I don't have the tools at home, I cannot even show you screenshots. But there are examples online now that you know what to look for.

Good luck.

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