cancel
Showing results for 
Search instead for 
Did you mean: 

Blank Report VB.net Winforms

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member188030
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Thank you for your reply, but unfortunately it didn't help.  Any other ideas what could cause this behavior?

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Answers (1)

Answers (1)

Former Member
0 Kudos

I found it, finally.  Thank you, Ludek and Bhushan, very much.  I appreciate your suggestions.  From the resources Ludek send I narrowed the issue to the GUID.  I found another forum post () and Jason Longs answer worked for me.