本文介绍了我如何将参数传递到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

推荐答案

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应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 06:04