pass parameteres on crystal report , logon information

agismarkos

New member
Joined
Oct 30, 2012
Messages
1
Programming Experience
Beginner
I want to search clients that got to shop between two dates. The code I use seems alright and it doesn't return any error but the CR returns everything - It does not use the date search function. The CR I use is tested with a simple program that open CR and works fine. database is ms access and code is in visual studio 2005

The second issue I have is that despite i use the connection info part it still ask me for a code
ps sorry if its wrong topic , wasnt sure were i should put it ;)



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)
'' For Each CRTable In cryRpt.Database.Tables
'CRTLI = CRTable.LogOnInfo
' With CRTLI.ConnectionInfo
With crConnectionInfo
.ServerName = "C:\Users\agis\Desktop\Insurance database\Insurancemanager.mdb"
.UserID = "Admin"
.Password = "vita"
.DatabaseName = "alfa"
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)
crParameterFieldDefinitions2 = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition2 = crParameterFieldDefinitions2.Item("enddate")
crParameterValues2 = crParameterFieldDefinition2.CurrentValues
crParameterValues2.Add(crParameterDiscreteValue2)
crParameterValues2.Clear()






crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
crParameterFieldDefinition2.ApplyCurrentValues(crParameterValues2)



CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub








End Class
 
Last edited:

Latest posts

Back
Top