水晶报表以获取特定记录 [英] Crystal report to get specific record
问题描述
嗨!我正在使用Crystal Report进行报告.但是问题是我不能在报表参数中使用相同的SQL命令,因为它与众不同.我将向您展示我的代码,以便您理解它.我有一份报告我有一个文本框和一个按钮的表格一个水晶报表查看器.我已经使用报表向导导入了所有字段.甚至我在那里都创建了parameter(name).这样,用户可以在文本框中输入特定的记录来获取特定的记录.但是这是我的button1代码:
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
当我点击获取报告(button1)按钮.我从结果表中得到了这种类型的结果.
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
我的意思是它显示了学生的ID&重新命名&再次在每一行.现在,我将向您展示我要制作哪种类型的报告.
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
这意味着它不会显示学生的ID和&重新命名&再次.在报告的顶部,它将显示学生的ID和姓名.一次&根据ID,它会在报告中显示学生的标记.我想我必须使用类似的选择*从结果中,其中text1.text =参数名称.但是问题是我不能在公式工作室中使用相同的命令.我想您现在可以感觉到我正在尝试做的事情.请帮助我&
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.
推荐答案
将学生ID"和名称"字段放在页眉"部分中,并将其他字段(主题和标记")放入其中在详细信息部分.现在您可以看到您的要求.
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.
这篇关于水晶报表以获取特定记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!