Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Crystal Report Parameters

Posted on 2012-08-14
4
Medium Priority
?
277 Views
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 vb.net 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
            ConMod.ConnectToDatabase()

            '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")
            rptMonthlyReport1.SetDataSource(ds)

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

Any help is appreciated.
0
Comment
Question by:SCOTT78
  • 2
4 Comments
 
LVL 101

Expert Comment

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

      rptMonthlyReport1.DiscardSavedData

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

mlmcc
0
 

Author Comment

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

Expert Comment

by:CodeCruiser
ID: 38292290
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?
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 300 total points
ID: 38292465
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.

mlmcc
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline
Suggested Courses

810 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