Re: Getting fresh data in a crystal report from a SQL database

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have the following code.

Private Sub genWorkOrderCompForOneCustomer()
If customerNameComboBox.Text = "Please Select a Customer" Then
MessageBox.Show("Please select a customer to create a report for.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If

Dim cryRpt As New WorkOrderCompleted_ForOneCustomer
cryRpt.Load()

Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue

crParameterDiscreteValue.Value = customerNameComboBox.Text
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition = crParameterFieldDefinitions.Item("CustomerName")
crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

CustomerReportCRV.ReportSource = cryRpt

End Sub


When I run the the application I am not getting the current information from the sql database until I hit the refresh button and enter the parameter. I would like the information to be up to date when first loading the application.
If someone can help me that would be great.


View the full article
 
Back
Top