Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created crystal report (cross tab). Am not using any dataset instead i used the wizrd in crystal report to call procedure from my Database schema (Provider given is Microsoft OLEDB provider for oracle, after which i gave my DB credentials(i.e. schema, username, password) and selected the procedure and selected the columns i wanted to display in the report).

There are 5 parameters that i need to pass it from front end to generate the report. While viewing the crystal report preview, by giving parameters, the report works fine.

Now i want to pass these 5 parameters from front end(vb.net) to show the report in the CrystalReportViewer. Please suggest the code to write in aspx.vb file. (PS:- I did go through other forums and found out some code, but all of them were giving some or the other error, so am posting one so that i can get the code specific to my requirement).

Thanks in advance..
Posted

1 solution

 
Share this answer
 
v2
Comments
rajeswarr1 4-Jul-12 9:32am    
Here is what i have added in my code:-

Dim report As ReportDocument = New ReportDocument

report.Load(Server.MapPath("rpt\CRReport.rpt"))
report.Refresh()
Dim fromdate As String = txtFromDate.Text
Dim todate As String = txtToDate.Text

Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo

Dim CrTables As Tables
Dim CrTable As Table

Dim crConnectionInfo As New ConnectionInfo()
With crConnectionInfo
.ServerName = "my server"
.DatabaseName = "my db"
.UserID = "my user"
.Password = "my pwd"
.IntegratedSecurity = False
End With

CrTables = report.Database.Tables

For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
If CrTable.Name IsNot Nothing Then
report.SetDataSource(CrTable.Name)
End If

Dim crParameterDiscreteValue As New ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues



crParameterFieldDefinitions = report.DataDefinition.ParameterFields

crParameterFieldLocation = crParameterFieldDefinitions.Item("param1")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue.Value = paramone.text
crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)


crParameterFieldLocation = crParameterFieldDefinitions.Item("param2")
crParameterValues = crParameterFieldLocation.CurrentValues
'crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = param2.selectedValue
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)


crParameterFieldLocation = crParameterFieldDefinitions.Item("param3")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue.Value = param3.text
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)


crParameterFieldLocation = crParameterFieldDefinitions.Item("param4")
crParameterValues = crParameterFieldLocation.CurrentValues
'crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = fromdate
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)


crParameterFieldLocation = crParameterFieldDefinitions.Item("param5")
crParameterValues = crParameterFieldLocation.CurrentValues
'crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = todate
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

CrystalReportViewer1.ReportSource = report
CrystalReportViewer1.RefreshReport()

But i dont see any records being shown on the crystal report.
Please lemme know if i have missed out something
rajeswarr1 4-Jul-12 9:36am    
Also i have tried this way of adding parameters
'report.SetParameterValue("param1", parmaone.text)
'report.SetParameterValue("param2", param2.selectedValue)
'report.SetParameterValue("param3", param3.text)
'report.SetParameterValue("param4", fromdate)
'report.SetParameterValue("param5", todate)

And still i dont see any records in the report....

I think the connection credentials that i have given is correct cos i can see the procedure that i am calling in the Report while debugging over this part
CrTable.Name

and also i can see the parameter values in report.ParameterFields()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900