在程序中向水晶报表传参数,以及在程序中指定报表源

            strPath = Application.StartupPath
            strPath = strPath & "/rpt/hurryReturn.rpt"
            myReportDoc.Load(strPath)

        '程序中向水晶报表传参数 
           Dim firstParameterValues As New ParameterValues
            Dim firstParameterValue As ParameterDiscreteValue
            firstParameterValue = New ParameterDiscreteValue(DataGrid1.Item(DataGrid1.CurrentRowIndex, 0))

            firstParameterValues.Add(firstParameterValue)

            Dim secondParameterValues As New ParameterValues
            Dim secondParameterValue As ParameterDiscreteValue
            secondParameterValue = New ParameterDiscreteValue
            secondParameterValue.Value = "aaa" 'Convert.ToString(DataGrid1.Item(DataGrid1.CurrentRowIndex, 1))
            secondParameterValues.Add(secondParameterValue)

            myReportDoc.DataDefinition.ParameterFields("@zdbh").ApplyCurrentValues(firstParameterValues)
            myReportDoc.DataDefinition.ParameterFields("@jyr").ApplyCurrentValues(secondParameterValues)
'程序中指定报表源
        Dim myTableLogonInfo As New TableLogOnInfo
        Dim myTable As Table
        For Each myTable In myReport.Database.Tables
            myTableLogonInfo = myTable.LogOnInfo
            With myTableLogonInfo.ConnectionInfo
                .ServerName = MainServerName
                .DatabaseName = MainDatabase
                .UserID = MainUser
                .Password = MainPass
            End With
            myTable.ApplyLogOnInfo(myTableLogonInfo)
        Next
        CrystalReportViewer1.ReportSource = myReport

转载于:https://www.cnblogs.com/zyizyizyi/archive/2004/12/19/2497869.html

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值