如何将参数从Vb.net组合框传递给reportviewer?

时间:2015-09-23 04:02:05

标签: vb.net

我正在使用Visual Studio express 2013并在VB.NET中编码。 我在Reportbuilder 3.0中使用参数(Plaasnaamprm)创建了一个报表。 我想通过我的Windows应用程序表单上的combobox将参数传递给报告。

当我运行我的应用程序时,我在reportviewer上收到以下错误消息:

  

"' Plaasnaamprm'参数缺少值"。

我尝试过这里描述的方法:How can I pass parameter to Reportviewer?

这是我的代码:

Imports System.Data.SqlClient
Imports System.Data.Sql
Imports Microsoft.Reporting.WinForms


Public Class Form2

  Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'SkeduleringDatabasisDataSet.Blokke' table. You can move, or remove it, as needed.
    Me.BlokkeTableAdapter.Fill(Me.SkeduleringDatabasisDataSet.Blokke)
    Dim Plaasnaamprm(0) As Microsoft.Reporting.WinForms.ReportParameter

    Dim cn As New SqlConnection
    cn.ConnectionString = My.Settings.SkeduleringDatabasisConnectionString
    cn.Open()
    Dim da As New SqlDataAdapter
    Dim sql As New SqlCommand("select * from blokke order by plaasnaam ", cn)
    Dim bs As New BindingSource
    Dim blokke As New DataTable
    Dim rds As New ReportDataSource("DataSet1", blokke)

    da.SelectCommand = sql
    da.Fill(blokke)
    bs.DataSource = blokke

    Plaasnaamprm(0) = New     Microsoft.Reporting.WinForms.ReportParameter("Plaasnaamprm,combobox1.selectedvaue")

    ReportViewer1.ProcessingMode = ProcessingMode.Local
    ReportViewer1.LocalReport.ReportPath = "C:\Users\Administrator   \Desktop\SKED PROGRAM\Skedulering_Mei_2015\Skeduleer2\Verslae\parskaartjies9.rdlc"
    ReportViewer1.LocalReport.SetParameters(Plaasnaamprm)
    ReportViewer1.LocalReport.DataSources.Add(rds)
    ReportViewer1.RefreshReport()

  End Sub
End Class

我很难过,所以任何帮助都会非常感激。 此致

1 个答案:

答案 0 :(得分:1)

我认为您没有传递参数所需的值。

尝试改变这一点:

Plaasnaamprm(0) = New     Microsoft.Reporting.WinForms.ReportParameter("Plaasnaamprm,combobox1.selectedvaue")

Plaasnaamprm(0) = New     Microsoft.Reporting.WinForms.ReportParameter("Plaasnaamprm",combobox1.selectedvalue)