0

I am using VS 2008 and SQL 2008,.I am trying to build a report using Report viewer using Parameters.I am completly new to this concept,so i was trying to develop using the basic steps as shown in various tutrials.

1> connect to dataset

2- Configure server

3 - table Adapter

4 - Add new report

5 - Drag a table in the Report screen and add the columns

6 * Here i am adding parameters ( fromdate,todate).Please tell me what mistake i am doing

I got to Reports -> ReportParamaters -> Add new Parameter - > fromdate -> type : Datetime. (Same for Todate)

7 - > In the web page. Added 2 textboxes and a button

8 - > Dragged Reportviewer - > choose Datasoure and Report name

Now the code Behind.

On button click

Protected Sub btnView_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnView.Click
        Try
            setReportParameters()
            Me.ReportViewer1.LocalReport.Refresh()
        Catch ex As Exception

        End Try
    End Sub

 Private Sub setReportParameters()
        Dim Fromdate As New ReportParameter("Fromdate", tbFromDate.Text)
        Dim Todate As New ReportParameter("Todate", tbtodate.Text)

        Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Fromdate, Todate})

    End Sub

When i Run the Report I get this Following Error

"

An error occurred during local report processing.
    Error during processing of ‘FromDate’ report parameter.

All i can see is the textboxes and Button.When i click on it,nothing happens...

Please help

"

4

2 回答 2

0

还有几件事要检查。

  1. 验证报告中的参数是否为 DateTime 数据类型。

  2. 您可能还需要格式化日期。我过去成功地使用过它:

    ReportParameter startAtParam = new ReportParameter("StartAt", startAt.ToString("MMM, dd yyyy"));

于 2012-04-10T12:58:26.717 回答
0

我看到两件事要检查:

1.)您使用参数“Fromdate”设置参数“fromdate”,我相信这是区分大小写的。

2.) 报告中的 Fromdate 是一个日期时间,您正在传递一个字符串 (tbFromDate.Text) 确保这是一个有效的日期。

 Dim Fromdate As New ReportParameter("Fromdate", cDate(tbFromDate.Text))
于 2012-04-09T23:33:58.523 回答