on 06-18-2015 8:37 PM
I used Crystal Reports 14.0.2 to build a report with a parameter field. The report works fine on my development machine. Then I called it from a VB.net, winform application using:
Dim RViewer As New ReportViewer
Dim CoProfile As New ReportDocument
CoProfile.Load("\\OZ\OZ Development\Assets\Company Profile.rpt")
CoProfile.SetDatabaseLogon("username", "password")
CoProfile.SetParameterValue("CompanyGUID", _obj.CompanyGUID.ToString)
RViewer.CrystalReportViewer1.ReportSource = CoProfile
RViewer.Text = "Company Profile for - " & _obj.CompanyName
RViewer.Name = "Company Profile"
RViewer.ShowDialog()
When I run the application I get a blank report:
The correct parameter is showing. And when I click the refresh button in the toolbar it asks for the parameter. If I give it the same exact parameter as was provided by the app and shows in the parameter panel I get the report rendered correctly.
What am I doing wrong? Thanks for your help.
Try refreshing the report object after loading the rpt and before setting anything.
Dim RViewer As New ReportViewer
Dim CoProfile As New ReportDocument
CoProfile.Load("\\OZ\OZ Development\Assets\Company Profile.rpt")
CoProfile.Refresh()
CoProfile.SetDatabaseLogon("username", "password")
CoProfile.SetParameterValue("CompanyGUID", _obj.CompanyGUID.ToString)
RViewer.CrystalReportViewer1.ReportSource = CoProfile
RViewer.Text = "Company Profile for - " & _obj.CompanyName
RViewer.Name = "Company Profile"
RViewer.ShowDialog()
Thanks,
Bhushan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See the sample apps here:
Crystal Reports for .NET SDK Samples - Business Intelligence (BusinessObjects) - SCN Wiki
In particular, check out vbnet_win_paramengine.zip, vbnet_win_multirangeparam.zip and vbnet_win_rangeparameters.zip. The following may also be of use:
vbnet_win_sub_daterange_param_engine.zip
Oh and maybe
SAP Crystal Reports .NET SDK Developer Guide
SAP Crystal Reports .NET API Guide
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow me on Twitter
Thank you, Ludek. I have reviewed the material you sent and have found there are a couple of ways to pass parameters from a VB.net application to a Crystal Report. I have tried a few.
Using the same code I started with but changing the parameter (and report filter) from a GUID to a integer it works. Now the code looks like:
Private Sub PrintFlowSheet()
Dim RViewer As New ReportViewer
Dim FloSheet As New ReportDocument
FloSheet.Load("\\OZ\OZ Development\Assets\Flow Sheet by EncNum.rpt")
FloSheet.SetDatabaseLogon("username", "password")
FloSheet.SetParameterValue("EncounterNum", 12380)
RViewer.CrystalReportViewer1.ReportSource = FloSheet
RViewer.Text = "Flow Sheet for - " & _objEmployee.FirstName & " " & _objEmployee.LastName
RViewer.Name = "Flow Sheet"
RViewer.ShowDialog()
End Sub
This has a hard coded Encounter number for testing purposes. But my question now is: Does Crystal Report support sqlGUIDs, and how do I handle them if they are. And suggestions for work arounds if they aren't.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.