Wednesday, March 21, 2012

Problem passing parameter from VB.Net 2005 to crystal - code included

I am trying to pass a few parameters to crystal from vb.net 2005. Here is what I have, and it is not working. Everything else on the report works fine. Any ideas?

It is asking me to enter the value in a new window when the report loads..."You can provide a single value for this parameter. Enter the value you want to include........."

Dim strReportPath1 As String = "MainSummary"
Dim strConnection As String = "Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=Carc2;"
Dim Connection As New SqlConnection(strConnection)
Dim strSQL As String = "My Select statement is here...too long to show in code"
Dim DA As New SqlDataAdapter(strSQL, Connection)
Dim DS As New DataSet

DA.Fill(DS, "SummaryInfo")

Dim strReportPath As String = Application.StartupPath & "\" & strReportPath1 & ".rpt"

If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
End If

If frmSummaryRpt.RadioShip.Checked = True Then
cr.SetParameterValue("ShipDate", frmSummaryRpt.txtStart.Text & " - " & frmSummaryRpt.txtEnd.Text)
ElseIf frmSummaryRpt.RadioShip.Checked = False Then
cr.SetParameterValue("ShipDate", "No ShipDate Selected")
End If

cr.Load(strReportPath)
cr.SetDataSource(DS.Tables("SummaryInfo"))This is resolved. The problem was that my if statements were before the report was loaded. I moved the area that they occured and it worked finesql

No comments:

Post a Comment