我想搜索在两个日期之间购物的客户。我使用的代码似乎没问题,它没有返回任何错误,但 CR 会返回所有内容 - 它不使用日期搜索功能。我使用的 CR 使用一个简单的程序进行测试,该程序打开 CR 并且工作正常。数据库是 ms 访问和代码是在 Visual Studio 2005
我遇到的第二个问题是,尽管我使用了连接信息部分,但它仍然要求我输入代码 PS。抱歉我的格式不好,我是stackoverflow的新手,我发现很难发帖谢谢!-阿吉西劳斯
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Form1
Dim crConnectionInfo As New ConnectionInfo()
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
cryRpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument
cryRpt.Load("C:\Users\agis\Documents\Visual Studio 2005\Projects\new_contracts _of_month\new_contracts _of_month\CrystalReport2.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
With crConnectionInfo
.ServerName = "C:\Users\agis\Desktop\Insurance database\Insurancemanager.mdb"
.UserID = "Admin"
.Password = "kos"
.DatabaseName = "insurancemanager"
End With
'first parameter
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterDiscreteValue.Value = Convert.ToDateTime(TextBox1.Text)
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("startdate")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Add(crParameterDiscreteValue)
crParameterValues.Clear()
' second parameter :
Dim crParameterFieldDefinitions2 As ParameterFieldDefinitions
Dim crParameterFieldDefinition2 As ParameterFieldDefinition
Dim crParameterValues2 As New ParameterValues
Dim crParameterDiscreteValue2 As New ParameterDiscreteValue
crParameterDiscreteValue2.Value = Convert.ToDateTime(TextBox2.Text)
TextBox3.Text += " " + crParameterDiscreteValue2.Value
crParameterFieldDefinitions2 = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition2 = crParameterFieldDefinitions2.Item("enddate")
crParameterValues2 = crParameterFieldDefinition2.CurrentValues
crParameterValues2.Clear()
crParameterValues2.Add(crParameterDiscreteValue2)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
crParameterFieldDefinition2.ApplyCurrentValues(crParameterValues2)
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub
End Class