pgkdavefdd
asked on
Visual studio 2008: passing parameters to crystal reports for VS2008 from asp.net 2.0 Web From using VB.net 2008
I have modified a crystal reports for VS2008 label report to print membership cards on business card stock. Using the crystal report default parameter prompt, I am able to enter member Id and the report is displayed. When I click on the crystal report viewer's print icon the export pop-up is displayed. However when I click on the export button, the default prompt screen is displayed and the report is not printed.
See the attached document for screen prints and my asp.net vb code.
The reports record selection is retrieving the data from a SQL2008 Server DB based upon the membersIDs parameter that contains the ID's entered in the report default parameter prompt in the crystal report viewer. Can anyone advise me what I have to do to get the report to print.
Do I have to modify my ASP.net screen to add an ASP.net listbox od CheckListBox linked to the MemberID column of the DBTable to collect the ID's? If so can anyone provide me with a code sample for collecting and passing mutiple selected ID's
MembersCardsreport.doc
See the attached document for screen prints and my asp.net vb code.
The reports record selection is retrieving the data from a SQL2008 Server DB based upon the membersIDs parameter that contains the ID's entered in the report default parameter prompt in the crystal report viewer. Can anyone advise me what I have to do to get the report to print.
Do I have to modify my ASP.net screen to add an ASP.net listbox od CheckListBox linked to the MemberID column of the DBTable to collect the ID's? If so can anyone provide me with a code sample for collecting and passing mutiple selected ID's
MembersCardsreport.doc
ASKER
The print button. I have also clicked on the export button and it does not work either.
ASKER
The following is code I modified from another form in which I pre-fill a list box with numbers to select a report number and the numbers are put into an array. See GetDefaultValuesFromParame terField(M emberTrans mittalRepo rt)
defaultParameterValuesList .DataBind( ) Bolded in code sample below:
Imports System.Collections
Imports System.Web.UI.WebControls
Imports CrystalDecisions.CrystalRe ports.Engi ne
Imports CrystalDecisions.Shared
Partial Class MemberTransmittal
Inherits System.Web.UI.Page
Private MemberTransmittalReport As ReportDocument
Private Const PARAMETER_FIELD_NAME As String = "MemberIDs"
Private Sub SetTableLocation(ByVal tables As Tables)
Dim connectionInfo As New ConnectionInfo()
connectionInfo.ServerName = "MYServer.com"
connectionInfo.DatabaseNam e = "CWVNat"
connectionInfo.UserID = "MY_ID"
connectionInfo.Password = "MY_Password"
For Each table As CrystalDecisions.CrystalRe ports.Engi ne.Table In tables
Dim tableLogOnInfo As TableLogOnInfo = table.LogOnInfo
tableLogOnInfo.ConnectionI nfo = connectionInfo
table.ApplyLogOnInfo(table LogOnInfo)
Next
End Sub
Private Sub ConfigureCrystalReports()
MemberTransmittalReport = New ReportDocument()
Dim reportPath As String = Server.MapPath("SelectCWVM embershipC ards.rpt")
MemberTransmittalReport.Lo ad(reportP ath)
SetTableLocation(MemberTra nsmittalRe port.Datab ase.Tables )
Dim myArrayList As ArrayList = New ArrayList()
If Not IsPostBack Then
defaultParameterValuesList .DataSourc e = GetDefaultValuesFromParame terField(M emberTrans mittalRepo rt)
defaultParameterValuesList .DataBind( )
myArrayList.Add("1176")
myArrayList.Add("1389")
myArrayList.Add("1450")
myArrayList.Add("1563")
myArrayList.Add("1690")
myArrayList.Add("2801")
myArrayList.Add("4942")
myArrayList.Add("11855")
myArrayList.Add("11895")
myArrayList.Add("11898")
Session("myArrayList") = myArrayList
Else
myArrayList = CType(Session("myArrayList "), ArrayList)
End If
SetCurrentValuesForParamet erField(Me mberTransm ittalRepor t, myArrayList)
CrystalReportViewer1.Repor tSource = MemberTransmittalReport
End Sub
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
ConfigureCrystalReports()
End Sub
Private Sub SetCurrentValuesForParamet erField(By Val myReportDocument As ReportDocument, ByVal myArrayList As ArrayList)
Dim currentParameterValues As ParameterValues = New ParameterValues()
For Each submittedValue As Object In myArrayList
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
myParameterDiscreteValue.V alue = submittedValue.ToString()
currentParameterValues.Add (myParamet erDiscrete Value)
Next
Dim myParameterFieldDefinition s As ParameterFieldDefinitions = myReportDocument.DataDefin ition.Para meterField s
Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinition s(PARAMETE R_FIELD_NA ME)
myParameterFieldDefinition .ApplyCurr entValues( currentPar ameterValu es)
End Sub
Private Function GetDefaultValuesFromParame terField(B yVal myReportDocument As ReportDocument) As ArrayList
Dim myParameterFieldDefinition s As ParameterFieldDefinitions = myReportDocument.DataDefin ition.Para meterField s
Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinition s(PARAMETE R_FIELD_NA ME)
Dim defaultParameterValues As ParameterValues = myParameterFieldDefinition .DefaultVa lues
Dim myArrayList As ArrayList = New ArrayList()
For Each myParameterValue As ParameterValue In defaultParameterValues
If (Not myParameterValue.IsRange) Then
Dim myParameterDiscreteValue As ParameterDiscreteValue = CType(myParameterValue, ParameterDiscreteValue)
myArrayList.Add(myParamete rDiscreteV alue.Value .ToString( ))
End If
Next
Return myArrayList
End Function
Protected Sub redisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles redisplay.Click
Dim myArrayList As ArrayList = New ArrayList()
For Each item As ListItem In defaultParameterValuesList .Items
If item.Selected Then
myArrayList.Add(item.Value )
End If
Next
Session("myArrayList") = myArrayList
ConfigureCrystalReports()
End Sub
End Class
Can Anyone advise me how to modify this to pass the selected values directly from the listbox if I bind it to the database. The list box is called "myArrayList"
defaultParameterValuesList
Imports System.Collections
Imports System.Web.UI.WebControls
Imports CrystalDecisions.CrystalRe
Imports CrystalDecisions.Shared
Partial Class MemberTransmittal
Inherits System.Web.UI.Page
Private MemberTransmittalReport As ReportDocument
Private Const PARAMETER_FIELD_NAME As String = "MemberIDs"
Private Sub SetTableLocation(ByVal tables As Tables)
Dim connectionInfo As New ConnectionInfo()
connectionInfo.ServerName = "MYServer.com"
connectionInfo.DatabaseNam
connectionInfo.UserID = "MY_ID"
connectionInfo.Password = "MY_Password"
For Each table As CrystalDecisions.CrystalRe
Dim tableLogOnInfo As TableLogOnInfo = table.LogOnInfo
tableLogOnInfo.ConnectionI
table.ApplyLogOnInfo(table
Next
End Sub
Private Sub ConfigureCrystalReports()
MemberTransmittalReport = New ReportDocument()
Dim reportPath As String = Server.MapPath("SelectCWVM
MemberTransmittalReport.Lo
SetTableLocation(MemberTra
Dim myArrayList As ArrayList = New ArrayList()
If Not IsPostBack Then
defaultParameterValuesList
defaultParameterValuesList
myArrayList.Add("1176")
myArrayList.Add("1389")
myArrayList.Add("1450")
myArrayList.Add("1563")
myArrayList.Add("1690")
myArrayList.Add("2801")
myArrayList.Add("4942")
myArrayList.Add("11855")
myArrayList.Add("11895")
myArrayList.Add("11898")
Session("myArrayList") = myArrayList
Else
myArrayList = CType(Session("myArrayList
End If
SetCurrentValuesForParamet
CrystalReportViewer1.Repor
End Sub
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
ConfigureCrystalReports()
End Sub
Private Sub SetCurrentValuesForParamet
Dim currentParameterValues As ParameterValues = New ParameterValues()
For Each submittedValue As Object In myArrayList
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
myParameterDiscreteValue.V
currentParameterValues.Add
Next
Dim myParameterFieldDefinition
Dim myParameterFieldDefinition
myParameterFieldDefinition
End Sub
Private Function GetDefaultValuesFromParame
Dim myParameterFieldDefinition
Dim myParameterFieldDefinition
Dim defaultParameterValues As ParameterValues = myParameterFieldDefinition
Dim myArrayList As ArrayList = New ArrayList()
For Each myParameterValue As ParameterValue In defaultParameterValues
If (Not myParameterValue.IsRange) Then
Dim myParameterDiscreteValue As ParameterDiscreteValue = CType(myParameterValue, ParameterDiscreteValue)
myArrayList.Add(myParamete
End If
Next
Return myArrayList
End Function
Protected Sub redisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles redisplay.Click
Dim myArrayList As ArrayList = New ArrayList()
For Each item As ListItem In defaultParameterValuesList
If item.Selected Then
myArrayList.Add(item.Value
End If
Next
Session("myArrayList") = myArrayList
ConfigureCrystalReports()
End Sub
End Class
Can Anyone advise me how to modify this to pass the selected values directly from the listbox if I bind it to the database. The list box is called "myArrayList"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mlmcc