如何在查询中创建between子句? [英] How should I create between clause in my query?

查看:101
本文介绍了如何在查询中创建between子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过以下代码在水晶报表中通过特定的ID显示信息.

I can show information by specific ID there in crystal report by following code.

Code : Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form6
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''Dim cryRpt As New ReportDocument
''cryRpt.Load(Application.StartupPath & "\CrystalReport5.rpt")
''CrystalReportViewer1.ReportSource = cryRpt
''CrystalReportViewer1.Refresh()
Dim cryRpt As New ReportDocument
cryRpt.Load(Application.StartupPath & "\CrystalReport5.rpt")
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("id")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
cryRpt.RecordSelectionFormula = "{Button1}= " & TextBox1.Text & ""
End Sub

但是我遇到了问题.我有一个表,其中有三个字段.日期一,收入一另一项费用.为了显示它,我有一个表单,两个文本框&一个水晶报表查看器.我的问题是要显示特定日期的记录很容易&我可以通过以前的代码来做到这一点.但根据用户,他想输入开始日期&结束日期以查看记录.那我现在该怎么办?你能帮我做吗?例如,他需要输入开始日期1-1-2010&结束日期2010年1月30日他想查看一月月份的所有报告,包括2010年1月1日& amp; 30-1-2010.我想我必须在查询中创建between子句.但是我很困惑如何创建它?我创建了两个参数.一是开始日期&另一个是结束日期.我应该在公式工作室中写些什么?对于一个参数,我写了这种类型的公式{asst.dt} = {?dt},但是对于两个日期&我应该写什么呢?我应该如何使用between子句?我需要帮助,请帮助我.

But I got a problem. I have a table where it has three fields. One for date one for income & another for expense. To show it I have a form two text boxes & one crystal report viewer. My problem is that to show a record of specific date is easy & I can do it by previous code. But according to user he wants to input starting date & end date to see records. So what should I do now? Can you please help me to do it? For example he needs to input starting date 1-1-2010 & end date 30-1-2010 & he wants to see all reports of January month including 1-1-2010 & 30-1-2010. I guess I have to create between clause in my query. But I am confused how should I create it? I have created two parameters. One is starting date & another is end date. What should I write there in formula workshop? For one parameter I had written this type of formula {asst.dt} = {?dt} but what should I write for two dates & how should I use between clause? I need help please help me.

推荐答案

asst.dt >= {?StartDate}  and asst.dt <= {?EndDate}


其中StartDate和EndDate是两个参数

有关更多信息,请检查此链接

http://vb.net-informations.com/crystal-report/vb.net_crystal_report_parameter_date.htm [ ^ ]


Where StartDate and EndDate are two parameters

For more information check this link

http://vb.net-informations.com/crystal-report/vb.net_crystal_report_parameter_date.htm[^]


这篇关于如何在查询中创建between子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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