>protected Sub Page_Load(ByVal sender As Object, ByVal e as System.EventArgs( Handle 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
我这台计算机上没有 Visual Studio 来完全测试这一点,但我认为您的语法在您的记录选择公式中是关闭的。
试试这个:
reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} in '" + date_from + "' to '" + date_to + "' and {VEWVoucherchq.chqbrNo} = " + user_brno
Crystal Reports 不支持您使用的between/and
语法,无法按照您想要的方式评估日期。 支持的语法是{eval_date} IN {start_Date} to {end_Date}
。
您还可能会遇到date_from
和date_to
字段为字符串数据类型而不是日期或日期时间数据类型的问题。 如果这是一个问题,您将希望通过函数传递值以将它们正确转换为日期。
这样的事情应该就足够了:
reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} in Date('" + date_from + "') to Date('" + date_to + "') and {VEWVoucherchq.chqbrNo} = " + user_brno
如果需要日期时间而不是日期数据类型,请将Date()
函数替换为DateTime()
函数。