我如何将参数传递到Visual Studio 2012中的Crystal Reports Windos应用程序中 [英] How do I pass paramters into a crystal Report in visual Studio 2012, windos Application

查看:100
本文介绍了我如何将参数传递到Visual Studio 2012中的Crystal Reports Windos应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个报告,我想传递一个datetime参数并将该参数显示在报告中.我有一个代码,但是转发中的字段仍然为空.

I have a report which I want to pass a datetime parameter and display that parameter into the report. I have a code but then the field in the repost is still blank.

Dim paramFields As New ParameterFields
               Dim paramField1 As New ParameterField
               Dim paramField2 As New ParameterField
               Dim discreteVal As New ParameterDiscreteValue


               discreteVal.Value = odDatumPicker.Value
               paramField1.ParameterFieldName = "@Datum"
               paramField1.CurrentValues.Add(discreteVal)
               paramFields.Add(paramField1)

    
               CrystalReportViewer1.ParameterFieldInfo = paramFields

推荐答案

您可以使用以下代码生成报告.
You can use the below code to generate the report.
Dim crReportDoc As New ReportDocument()
Dim crpConnectionInfo As New ConnectionInfo()
crReportDoc.Load(FilePath)
crpConnectionInfo.AllowCustomConnection = True
crpConnectionInfo.ServerName = [servername]
crpConnectionInfo.DatabaseName = [dbname]
crpConnectionInfo.UserID = [username]
crpConnectionInfo.Password = [password]

For Each tblCurrent In _crReportDoc.Database.Tables
    crpTableLogonInfo = tblCurrent.LogOnInfo
    crpTableLogonInfo.ConnectionInfo = crpConnectionInfo
    tblCurrent.ApplyLogOnInfo(crpTableLogonInfo)
Next
crReportDoc.VerifyDatabase()
crReportDoc.SetParameterValue("@Datum", odDatumPicker.Value)
CrystalReportViewer1.ReportSource = crReportDoc


请更改ConnectionInfo


Please change the ConnectionInfo


这篇关于我如何将参数传递到Visual Studio 2012中的Crystal Reports Windos应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆