我在将组合框值传递给水晶报告时遇到问题我是水晶报告的新手,所以我真的需要你的帮助!
这是我的代码:
dir = Path.GetFullPath(dir)
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
Dim reportsfolder As String = Application.StartupPath + "\PrintArea\LoanProdReport.rpt"
Dim report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim DS As New DataSet
Dim query As String
query = "SELECT * FROM ClientDatabase"
Dim DA As New SqlDataAdapter(query, jonsqlcon)
DA.Fill(DS)
report.Load(reportsfolder)
report.SetDatabaseLogon(dbSettingsAdder.TBUserID.Text, dbSettingsAdder.tbPassword.Text)
crParameterFieldDefinitions = report.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("YearHeader")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = ComboBoxEx2.SelectedItem.ToString
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
report.SetDataSource(DS.Tables(0))
LoanProdRpt.CrystalReportViewer1.ReportSource = report
LoanProdRpt.CrystalReportViewer1.Refresh()
LoanProdRpt.ShowDialog()
正如您所见,我正在尝试将Combobox值传递给参数YearHeader。
任何帮助将不胜感激。在此先感谢:)
答案 0 :(得分:0)
我多么愚蠢,我只是这样做了
dir = Path.GetFullPath(dir)
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
Dim reportsfolder As String = Application.StartupPath + "\PrintArea\LoanProdReport.rpt"
Dim report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim DS As New DataSet
Dim query As String
query = "SELECT * FROM ClientDatabase"
Dim DA As New SqlDataAdapter(query, jonsqlcon)
DA.Fill(DS)
report.Load(reportsfolder)
report.SetDatabaseLogon(dbSettingsAdder.TBUserID.Text, dbSettingsAdder.tbPassword.Text)
report.SetDataSource(DS.Tables(0))
crParameterFieldDefinitions = report.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("YearHeader")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = ComboBoxEx2.SelectedItem.ToString
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
LoanProdRpt.CrystalReportViewer1.ReportSource = report
LoanProdRpt.CrystalReportViewer1.Refresh()
LoanProdRpt.ShowDialog()