Help: Problem with Crystal Reports XI

abo0badr

Member
Joined
Nov 22, 2012
Messages
9
Programming Experience
3-5
I have created a report using crystal reports XI, and all things are good. I can view the users which is listed in my database table.
But one thing I noticed is whenever I add a user to my database during run-time (on the Application), and then I go back to the reports in my Application, when I click the button where I link the Crystal_report_viewer, the users, or the table is not refreshed. Or not filled with the new user that was added/inserted to the table.


Kindly if someone knows how to refresh it, it would be a pleasure for me hearing from you guys.
Happy holidays guys.


PS: I created a .rpt first in Crystal Reports, and then on my .Net project I add the SQL query,connection to the dataset,etc. and then open the .rpt file from the .net using codes.
 

IanRyder

Well-known member
Joined
Sep 9, 2012
Messages
1,130
Location
Healing, NE Lincs, UK
Programming Experience
10+
Hi,

This depends on how you have set things up but the way I ensure my reports return the most up to date data is to always query the data source first before viewing the reports in the viewer. See if this helps:-

VB.NET:
Dim sqlConn As New SqlConnection("YourConnectionString")
Dim da As New SqlDataAdapter("Select * from Customers", sqlConn)
Dim dt As New DataTable
da.Fill(dt)
CrystalReport1.SetDataSource(dt)
 CrystalReportViewer1.ReportSource = CrystalReport1

Hope that helps.

Cheers,

Ian
 

abo0badr

Member
Joined
Nov 22, 2012
Messages
9
Programming Experience
3-5
Thanks for the reply. I just found out that I missed the part where it refreshes the report.
I searched and found that I should add the
CrystalReportViewer1.RefreshReport()

But my problem now is it is not filtering my report. I modified my Select Query to get only 1 user depending on the selected record from the datagridview. but it still returns all the data on that table. it should return only the specific user

what shall I do?
 
Top Bottom