Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9008

Provide value to SQL SP parameter from VB.NET via CrystalReportDocument

$
0
0

(I'm having a tough time using this editor -- why can't I paste into it?)

 

I'm developing a CrystalReportDocument from within Visual Studio for the first time, and cannot get the report to work.  My environment is VB.NET in Visual Studio 2013, Crystal Reports for Visual Studio 2013 SP9, and SQL Server Express 2014.

 

The report Invoice.rpt appears in the Solution Explorer window of my VB.NET project. It uses a SQL Server SP containing one parameter, @RepairOrderNumber, that needs to be supplied at run time. Here's my code that attempts to invoke the report:

 

     Private Sub frmReportViewer_Load(sender As Object, e As EventArgs) Handles MyBase.Load

          Try

               Dim rptInvoice As New SD.Invoice          ' this is supposed to reference Invoice.rpt

               Dim crParameterField As New ParameterField

               Dim crParameterFields As New ParameterFields

               Dim crParameterDiscreteValue As New ParameterDiscreteValue


               crParameterField.Name = "@RepairOrderNumber"

               crParameterDiscreteValue.Value = 2        ' hard-coded for now to print invoice number 2 

               crParameterField.CurrentValues.Add(crParameterDiscreteValue)

               crParameterFields.Add(crParameterField)


               crViewer.ParameterField.Info = crParameterFields

               crViewer.ReportSource = rptInvoice


          Catch ex As Exception

               ' error logging code omitted, but no errors were logged.


          End Try

     End Sub


When I run the above code, the Invoice report is displayed in the viewer, however it's empty -- apparently no result set is being returned.  When I preview the report in the designer and supply a parameter value when prompted, the report displays perfectly.

 

What's wrong with the above code?

 

Thanks in advance...


Viewing all articles
Browse latest Browse all 9008


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>