Crystal Report Parameters

Posted on 2012-08-14
Last Modified: 2012-10-11
Hi, I have a dataset attached to my crystal report which returns specific results. When testing the query my results return my specific records. However, when I run it in my crystal report I get all records in my table. It is as if my sql query is not being recognized by the report? Im using 2008.

The code for my report is below:

            Dim ds As New DataSet

            Dim sqlString As String = "SELECT l.JobNo,l.Description,l.Solution,l.JobLoggedDate,l.DateComplete,l.Parts,l.RaisedBy," & _
                "l.Customer,c.Company FROM tblJobsList l INNER JOIN tblCustomers c ON l.Customer = c.ID " & _
                "WHERE c.Company = '" & gbCustomer & "' AND l.JobLoggedDate >= '" & ScottFunc.ConvertDate(gbFromDate) & "' " & _
                "AND l.DateComplete <= '" & ScottFunc.ConvertDate(gbToDate) & "' ORDER BY l.JobLoggedDate "

            'Open Database

            'Create a sql adapter from criteria entered then fill the dataset
            Dim daService As New SqlDataAdapter(sqlString, myConnection)

            'Fill adapter and assign table
            daService.Fill(ds, "JobsList")

            'Set SQL to Report
            rptMonthlyReport1.SetDatabaseLogon("sa", "gotham")

            'Assign the Report to show to the viewer
            crViewer.ReportSource = rptMonthlyReport1

Any help is appreciated.
Question by:SCOTT78
    LVL 100

    Expert Comment

    Is the report saved with data?
    That is the Crystal default.
    Try adding this line before you assign the datasource


    If you refresh the report does it show the correct results?


    Author Comment

    Thanks for the suggestion but it doesnt work. I have tried using 'load' and 'refresh' but neither of them make a difference.
    LVL 83

    Expert Comment

    How was the report designed? Using a dataset or using the database? Why do you need

     rptMonthlyReport1.SetDatabaseLogon("sa", "gotham")

    if you are using a dataset?
    LVL 100

    Accepted Solution

    Good point.  I believe to have a report use a dataset it must be built against a dataset otherwise it will look for and use the database.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now