Crystal Reports 再次要求提供参数值

Crystal Reports asking for parameter values again

提问人:Raffy 提问时间:7/25/2023 最后编辑:Sebastian BroschRaffy 更新时间:7/25/2023 访问量:38

问:

我在 Crystal Reports 中出现问题,显示对话框询问我的值,但我已经在该参数上有我的值。为什么连我都有价值观还要问?你能帮我解决这个问题吗?insertquery

法典

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
    If DateDiff(DateInterval.Day, CDate(dtpFrom.Value.ToShortDateString), CDate(dtpTo.Value.ToShortDateString)) < 0 Then
        MessageBox.Show("Invalid Date Range", "Invalid Date", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

    If dgCustomer.Rows.Count = 0 Then
        Exit Sub
    End If

    Dim report_Batch As New BILLINGRBatch
    Dim strName As String = ""
    Dim strSelect As String = ""
    For i As Integer = 0 To dgCustomer.Rows.Count - 1
        If CBool(dgCustomer.Item(0, i).Value) = True Then
            Dim intId As Integer = dgCustomer.Item(1, i).Value
            strName = Replace(Trim(dgCustomer.Item(2, i).Value), "'", "''")

            Dim payFilter As String = ""
            If txtPayId.Text <> 0 Then
                payFilter = " AND a.status = '" & txtPayId.Text & "'"
            End If

            Dim dateFilter As String = ""
            If dtpFrom.Value <> dtpTo.Value Then
                dateFilter = " AND (SELECT start_date FROM bill_transaction1 WHERE transaction_id = a.transaction_id) BETWEEN ''" & dtpFrom.Value.ToString("yyyy-MM-dd") & "'' AND ''" & dtpTo.Value.ToString("yyyy-MM-dd") & "''"
            End If
            strSelect = "insert into @t (customerid, customername,payFilter,dateFilter) select '" & intId & "','" & strName & "','" & payFilter & "','" & dateFilter & "' " & Chr(13)
        End If
    Next

    For Each table As CrystalDecisions.CrystalReports.Engine.Table In report_Batch.Database.Tables
        Dim logonInfo As CrystalDecisions.Shared.TableLogOnInfo = table.LogOnInfo
        logonInfo.ConnectionInfo.ServerName = serverName
        logonInfo.ConnectionInfo.DatabaseName = serverDB
        logonInfo.ConnectionInfo.UserID = serverUser
        logonInfo.ConnectionInfo.Password = serverPass
        table.ApplyLogOnInfo(logonInfo)
    Next

    For Each subReport As ReportDocument In report_Batch.Subreports
        For Each Table As Table In subReport.Database.Tables
            Dim logonInfo As CrystalDecisions.Shared.TableLogOnInfo = Table.LogOnInfo
            logonInfo.ConnectionInfo.ServerName = serverName
            logonInfo.ConnectionInfo.DatabaseName = serverDB
            logonInfo.ConnectionInfo.UserID = serverUser
            logonInfo.ConnectionInfo.Password = serverPass
            Table.ApplyLogOnInfo(logonInfo)
        Next
    Next
    report_Batch.SetParameterValue("insertquery", strSelect) 'this is my insertquery values
    report_Batch.SetParameterValue("customername", strName)


    frm_printing.crp_report.ReportSource = report_Batch
    frm_printing.crp_report.Zoom(100%)
    frm_printing.crp_report.Refresh()
    frm_printing.ShowDialog()
End Sub
vb.net 参数 crystal-reports 参数传递

评论

0赞 Raffy 7/25/2023
有人可以帮我吗?或者有人遇到这个问题?谢谢

答:

0赞 Sebastian Brosch 7/25/2023 #1

这是由设置参数值后引起的。如果从代码中删除以下行,则报告应按预期工作:.Refresh

frm_printing.crp_report.Refresh()

评论

0赞 Raffy 7/26/2023
我删除了我的,但它仍然询问我的参数的值frm_printing.crp_report.Refresh()insertquery