Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 3-Jul-12 19:17pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
rajeswarr1 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 445
1 CHill60 410
2 Sergey Alexandrovich Kryukov 354
3 BillWoodruff 190
4 PIEBALDconsult 160


Advertise | Privacy | Mobile
Web03 | 2.8.141015.1 | Last Updated 4 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100