Click here to Skip to main content
15,910,603 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have DataGridView that returns different number of columns every time , so I need to display this different number of columns in crystal report
this is some part of code
thank you ,,

What I have tried:

Dim sqlsubjects As String = "SELECT DISTINCT Subjects.SubjectID,  Subjects.SubjectCode, Subjects.SubjectName, Subjects.SubjectHours,StudentSubjects.SubjectTypeReults "
           sqlsubjects = sqlsubjects + "FROM Subjects, StudentSubjects  "
Posted
Updated 5-Jul-17 18:27pm
v2

1 solution

Sorry but Crystal doesn't work that way. Crystal uses a pre-defined data object to display the data in a specified format.
If you pass a different data object then it will give you errors that it cannot locate column xyz.
Either;
a) Always pass the same number of columns & use some type of flag in the data to tell Crystal what columns to show. This is complicated because you would also need to set the position of the elements
b) Create individual reports for each scenario
c) Change the format of your Report

I would personally go with Option C. Group the Subjects by Student and then show the Subjects, Hours, Results etc in a table below each Student

Kind Regards
 
Share this answer
 
v2

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