受保护的子Page_Load(ByVal发件人作为对象,ByVal e作为System.EventArgs)处理Me.Load
reportdoc1.Load(Server.MapPath("~\RepVoucherchq.rpt"))
CrystalReportViewer1.ReportSource = reportdoc1
ConnectionInfo()
Dim user_brno As String = CType(Session("userBrn"), String)
Dim date_from As String = CType(Session("date_from"), String)
Dim date_to As String = CType(Session("date_to"), String)
reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} between '" + date_from + "' and '" + date_to + "' and {VEWVoucherchq.chqbrNo} = " + user_brno
CrystalReportViewer1.RefreshReport()
End Sub
发布于 2018-07-03 03:04:12
我没有在这台计算机上安装Visual Studio来完全测试这一点,但我认为你的语法在你的记录选择公式中是错误的。
试着这样做:
reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} in '" + date_from + "' to '" + date_to + "' and {VEWVoucherchq.chqbrNo} = " + user_brno
水晶报表中不支持您使用的between/and
语法来按您想要的方式评估日期。支持的语法为{eval_date} IN {start_Date} to {end_Date}
。
当您的date_from
和date_to
字段是字符串数据类型而不是Date或DateTime数据类型时,也可能会遇到问题。如果这是一个问题,您将希望通过一个函数传递这些值,以便将它们正确地转换为日期。
这样的代码应该就足够了:
reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} in Date('" + date_from + "') to Date('" + date_to + "') and {VEWVoucherchq.chqbrNo} = " + user_brno
如果需要DateTime而不是Date数据类型,请将Date()
函数替换为DateTime()
函数。
https://stackoverflow.com/questions/51137511
复制相似问题