水晶报表中的多个参数 [英] Multiple parameter in crystal report

查看:69
本文介绍了水晶报表中的多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在Crystal报表中传递两个参数.我可以使用1个参数.
请帮忙,我想在另一个文本框中传递另一个参数.

I am not able to pass two parameter in crystal report. I can do with 1 parameter.
Please help, I want to pass another parameter in another textbox.

Dim rpt As New CrystalReport_booking
Dim ReportPath As String = Application.StartupPath & "\CrystalReport_booking"
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues()
Dim crParameterDiscreteValue As New ParameterDiscreteValue()

crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions("bno")
crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

Catch ex As Exception
     MsgBox(ex.Message)
End Try

推荐答案

只需在报告中创建另一个参数字段.在代码中,只需复制粘贴第一个参数thing&将其更改为第二个参数.
Just create another parameter field in report. And in Code just copy-paste the 1st parameter thing & change it for second parameter.
Dim rpt As New CrystalReport_booking
Dim ReportPath As String = Application.StartupPath & "\CrystalReport_booking"
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues()
Dim crParameterDiscreteValue As New ParameterDiscreteValue()
 
crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions("bno")
crParameterValues = crParameterFieldDefinition.CurrentValues

'Second parameter Coding 
crParameterDiscreteValue.Value = TextBox2.Text 'Second textbox
crParameterFieldDefinitions = rpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions("second")'Second parameter
crParameterValues = crParameterFieldDefinition.CurrentValues
 
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
 
Catch ex As Exception
     MsgBox(ex.Message)
End Try



供您参考

VB.NET Crystal Reports字符串参数 [



For your information

VB.NET Crystal Reports String parameter[^]


例如,您的两个文本框包含一些与日期有关的信息,您希望获取这两个日期之间的信息以显示在Crystal Report窗体上.

上面的方法是一种,然后再有一种更简单的方法.
将会使用ReportSource选项

Say for example your two text box contain some information related to date and you want to get the information between those two dates to display on the Crystal Report form.

The way you did above is one, and then there is one more easier way of doing the same.
The would be to use the ReportSource option

Dim ds As New DataSet
Dim commandResult As OleDbCommand = New OleDbCommand("your querry based on the 2 fields applicable to the table")

commandResult.CommandType = 1
commandResult.Connection = cno
commandResult.ExecuteNonQuery()

Dim adapter As OleDbAdapter = New OleDbAdapter

adapter.SelectCommand=commandResult
adapter.Fill(ds)

Dim report As New CrystalReport1

report.SetDataSource(ds.Tables(0))

Form.CrystalReportViewer1.ReportSource=report
Form.CrystalReportViewer1.Refresh()



前提是您已完成其他所有操作,例如成功连接数据库和其他必要的操作.



This is done assuming that you have done the rest of the things, like connecting to the Database and other necessary things successfully.


这篇关于水晶报表中的多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆