VB.NET - How to convrt this in VB net - Asked By Ralph Acido on 10-Aug-06 11:41 PM

'This program was created in vb 6.0 anyone whoe can help on how to convert this in VB.net program... this is used to load a crystal report...thanks!

Dim crxApplication As New CRAXDRT.Application
    Dim crxReport As New CRAXDRT.Report
    Animate = True
    'The following line changes the mouse pointer to an hour glass while the report is loading.
    Screen.MousePointer = vbHourglass

    'Use the DiscardSavedData method to ensure that your report hits the Database and refreshes the data
    cr_coll_advance.Database.Tables(1).ConnectionProperties.Item("Data Source") = uoINI.ProfileString("general", "data source", "none")
    'MsgBox CrystalReport1.Database.Tables(1).ConnectionProperties.Item("data source")
    'Set the Parameters for the Main Report

    'Customer ID parameter. This is a number range parameter.
    'Use the rangeInfo enumerated constants to include lower bound and uppper bound values
    'The following line clears the value of the report parameter.
    'The following line populates the report parameter with new data.
    cr_coll_advance.ParameterFields(1).AddCurrentValue CDate(date1)
    cr_coll_advance.ParameterFields(2).AddCurrentValue CDate(date2)
    'Set the parameter for the Subreport
    'First open the Subreport
    'Now set the parameter for the subreport

    'Hire Date parameter. This is a date-time range parameter.
    'Use the rangeInfo enumerated constants to include lower bound and uppper bound values
    'Set the ReportSource of the CrViewer control to the Report object and view the report.
    CRViewer91.ReportSource = cr_coll_advance
    'Maximize the window state so we can view the whole report.
    'frm_print_list_of_enrollees.WindowState = vbMaximized
    'Zoom the preview window to 100% and return the mouse pointer to its previous icon
    CRViewer91.Zoom 100
    Screen.MousePointer = vbDefault
End Sub

Example - Asked By Rupali Randhave Kolhe on 11-Aug-06 01:33 AM

Read this e.g
************************************************************************How do I pass parameters into a Crystal Report from VB.NET?
You can programmatically pass parameter values into your Crystal Report using VB.NET code similar to this:

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    ' Load the selected report file.
    Dim CR As New ReportDocument
    ' Declare the parameter related objects.
    Dim crParameterDiscreteValue As ParameterDiscreteValue
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    Dim crParameterFieldLocation As ParameterFieldDefinition
    Dim crParameterValues As ParameterValues
    ' Get the report's parameters collection.
    crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
    ' Set the first parameter
    ' - Get the parameter, tell it to use the current values vs default value.
    ' - Tell it the parameter contains 1 discrete value vs multiple values.
    ' - Set the parameter's value.
    ' - Add it and apply it.
    ' - Repeat these statements for each parameter.
    crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
    crParameterValues = crParameterFieldLocation.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    crParameterDiscreteValue.Value = strStartDate
    ' Set the Crytal Report Viewer control's source to the report document.
    CrystalReportViewer.ReportSource = CR

If your report's DataSource is a .NET DLL DO NOT set the ReportDocument's DataSource property programatically as in the code below. However, if the DataSource is an XML Schema (.xsd) file you must set it prior to setting your parameters.


If your report's DataSource is a .NET DLL as shown here and the public functions that return the datatables available to your report where changed to require parameters, as illustrated below, the parameters can be set as just described. 

    Public Function Customers(theStartDate As String) As DataTable

If the parameters were added to your Crystal Report by clicking the Parameter Fields node in the Crystal IDE's Field Explorer they can be set using the following code: 

    Dim cr As New ReportDocument
    cr.SetParameterValue("StartDate", strMyParmValue)
    CrystalReportViewer.ReportSource = cr

refer this links