Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB.Net vs VB with Crystal Reports 11 Viewer
Message
General information
Forum:
ASP.NET
Category:
Reporting
Miscellaneous
Thread ID:
01027081
Message ID:
01028240
Views:
8
This message has been marked as a message which has helped to the initial question of the thread.
Hi,

Here's a bit of code I use:
 Private Sub ShowReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowReport.Click

        Dim oReport As CrystalDecisions.CrystalReports.Engine.ReportDocument
        oReport = SetUpReport(txtStartDate.Text, txtEndDate.Text)

        'CView is CD Web reportviewer 
        CView.ReportSource = oReport
        CView.Visible = True
    End Sub

    Private Function SetUpReport(ByVal StartDate As String, ByVal EndDate As String) As CrystalDecisions.CrystalReports.Engine.ReportDocument

        Dim BL As New LVBLayer.CInfo
        Dim ds As DataSet

        Dim SD As Date = CType(StartDate, Date)
        Dim ED As Date = CType(EndDate, Date)
        ds = BL.GetInterceptsForPeriod(SD, ED)
        Dim oReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        With oReport
            .Load("report.rpt")
            .SetDataSource(ds)
            .SetParameterValue("StartDate", SD)
            .SetParameterValue("EndDate", ED)
        End With
        Return oReport
    End Function
SetUpReport is only a seperate function because it's also used when producing PDF / Excel versions of the report. The dataset for the report is selected based on the input values. I'm only passing these to the Crystal report document because they are used in the report heading.

BTW, the .NET template you were attempting to add is only the cut-down Crystal reports designer that is provided with Visual Studio. If you have the full version of Crystal Decisions to create the .RPT file then you have no real need for it.

HTH,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform