Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Parameters appear using crystal report

$
0
0

Hi,

I have 2 Crystal Report with 1 parameter each. These parameters are used to link the two reports. When I created these reports, it was in the SERVER 1. My program selects the "SERVER" and "DATABASE" the user wishes to connect. So I created it dynamically. The program works fine and the report displays the correct output if the user selects a different "DATABASE". But when the user selects a different "SERVER" (SERVER 2), it displays the parameter I created in the Crystal Report.

I'm using VB.net. Also, I've attached my code below for review.

Please help. Thanks in advance.

Dim cr1 As CrystalDecisions.CrystalReports.Engine.ReportDocument

'the parameters'
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues


cr1 = New rptPOForm


Dim CTableLogInfo As TableLogOnInfo
Dim ConnInfo As CrystalDecisions.Shared.ConnectionInfo = New ConnectionInfo()
ConnInfo.Type = ConnectionInfoType.CRQE
ConnInfo.ServerName = thesqlserver
ConnInfo.DatabaseName = thedbssis
ConnInfo.UserID = thedbid
ConnInfo.Password = thepassword
ConnInfo.AllowCustomConnection = False
ConnInfo.IntegratedSecurity = False


For Each CTable As Table In cr1.Database.Tables
	CTable.LogOnInfo.ConnectionInfo = ConnInfo
	CTableLogInfo = CTable.LogOnInfo
	CTableLogInfo.ReportName = cr1.Name
	CTableLogInfo.TableName = CTable.Name
	CTable.ApplyLogOnInfo(CTableLogInfo)
Next



'parameter entries'
crParameterFieldDefinitions = cr1.DataDefinition.ParameterFields
crParameterFieldLocation = crParameterFieldDefinitions.Item("mainParameter1")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = thedbssis
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)


frmReport.CrystalReportViewer1.ReportSource = cr1

frmReport.CrystalReportViewer1.Dock = DockStyle.Fill
frmReport.CrystalReportViewer1.ShowGroupTreeButton = True
frmReport.CrystalReportViewer1.ReportSource = cr1
frmReport.CrystalReportViewer1.Refresh()
frmReport.CrystalReportViewer1.Show()

frmReport.Show()




Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>