Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I am using crystal report to make my report. But problem is that I cant use same SQL Command there in report parameter because its different. I am going to show you my code so that you can understand it. I have a report & a form where I have one text box one button & one crystal report viewer. I have imported all fields by using report wizard. Even I have created parameter(name) there. So that user can get specific record by typing it there in the text box. However here is my code for button1:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
    Inherits System.Windows.Forms.Form
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        cryRpt.Load(Application.StartupPath & "\CrystalReport1.rpt")
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue
        crParameterDiscreteValue.Value = TextBox1.Text
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = crParameterFieldDefinitions.Item("name")
        crParameterValues = crParameterFieldDefinition.CurrentValues
        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class

When I click on get report(button1) button. I get this type of result from result table.

ID Number Student`s nameSubject`s nameObtained mark
  DEN01010          John                    English               60
  DEN01010          John                    Math                  50
  DEN01010          John                    Computer              70

I mean it shows student`s ID & name again & again in every row. Now I am going to show you what type of report I want to make.

                    ID Number Student`s name
                          DEN01010        John                          
Subject`s name Obtained mark
       English               60
       Math                  50
       Computer              70


It means it will not show student`s ID & name again & again. On the top of the report it will show student`s ID & name for once & depending on ID it will show student`s mark on report. I guess I have to use something like that Select * from result where text1.text = name of the parameter. But problem is that I cant use same command there in formula workshop. I guess you can feel it now what I am trying to do. Please help me & explain it step by step because I am just a beginner.
Posted
Updated 25-Jun-10 11:00am
v2

1 solution

Put the Student Id & Name fields in Page Header Section & put the other fields (Subject & Mark) in Details section. Now you can see your requirement.
 
Share this answer
 

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