我想搜索兩個日期之間購物的客戶。 我使用的代碼似乎很好,它不會返回任何錯誤,但CR會返回所有內容 - 它不使用日期搜索功能。我使用的CR是用一個簡單的程序打開CR並且工作正常。 數據庫是MS訪問和代碼是在Visual Studio 2005通過晶體報告參數,連接訪問代碼,vb.net
我的第二個問題是,儘管我使用連接信息部分它仍然要求我的代碼 聚苯乙烯。對不起,我的格式不好,我是新的在stackoverflow,我覺得很難做一個帖子 謝謝! -Agisilaos
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
感謝您的回覆。結果發現該報告出了問題。但現在我有另一個問題。它不傳遞參數。我得到CR插入參數的提示。請指教,謝謝 –
參數名稱是區分大小寫 –
沒有它不是說:( –