问题描述
我使用了这个从论坛传来的值,从textbox传递值到crystal report.I在这一行中出错了
I used this coding which took from a forum to pass value from textbox to crystal report.I got an error in this line
crParameterFieldDefinition = crParameterFieldDefinitions.Item("@MajorName", Me.TextBox1.Text)
说索引超出范围
但是当改变编码时这个
saying index is out of bounds
but when change the coding as this
crParameterFieldDefinition = crParameterFieldDefinitions.Item("@MajorName")
我收到错误索引无效。 (HRESULT异常:0x8002000B(DISP_E_BADINDEX))
I got an error Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
Dim cryRpt As New ReportDocument
Dim report As New CrystalReport1
Dim major As String
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = report.DataDefinition.ParameterFields()
<pre lang="text"> crParameterFieldDefinition = crParameterFieldDefinitions.Item("@MajorName", Me.TextBox1.Text)
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues .Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
推荐答案
这篇关于如何在vb.net 2008和SQl 2005中将值从文本框传递到水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!