Avatar of indikad
indikad asked on

how do I refresh Crystal report programatically to discard saved data Crsytal report viewer C# Visual Studio 2005

I am using the Crsyal report viewer control in C# ( Visual Studio 2005)
I use the attached code
the report loads - but loads with the saved data. I want it to refresh automatically.  

Thanks in advance.
rd.FileName = sPath;
 CrystalDecisions.Shared.TableLogOnInfo myLogin;
 foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in rd.Database.Tables )
                myLogin = myTable.LogOnInfo;
                myLogin.ConnectionInfo.Password = "pwd"; 
                myLogin.ConnectionInfo.UserID = "sa";
                myLogin.ConnectionInfo.DatabaseName = "dbname";
                myLogin.ConnectionInfo.ServerName = "servername";
            crystalReportViewer.ReportSource = rd;            

Open in new window

.NET ProgrammingCrystal Reports

Avatar of undefined
Last Comment

8/22/2022 - Mon

when you save the report, uncheck the options where it says
saved data with report
Mike McCracken

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question


does not have a DiscardSAvedData .

did I use the incorrect class?

it is funny that the ReportDocument object (
has all the methods and properties but not the discard saved data?


saving the report without data is not an option for me. since I do not create the reports. I develop the Crystal Viewer only.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Mike McCracken

Does the viewer?

Mike McCracken

What viewer are you using?


I use the Viewer supplied with the Visual Studio. and the Viewer control has no method to support DiscardSAvedData .
I know that the Viewer supplied with the Crsytal designer had , I had a VB6 app , and I used it in it.
But since now I am converting the VB6 to C#, I am stuck on this.
but I have sometimes seen the report refresh I must say  - on the development machine, but I remember when I tested on a deployed machine a week ago, the report did not refresh initially. I had to clcik the refresh button
if you have any ideas off the top of your head, pls reply.
Otherwise, I am planning to do more stringent tesing in the next 3 days, and I will update this message then.
Thanks very much.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mike McCracken

Is this the version of Crystal included with VS or a standalone?
If standalone there should be a viewer included with it.

I haven't used VS so not sure about that viewer.

ANy real reason they save data woth the reports?
It is an easy fix to avoid that.


This is the VS included one. However since yesterday the requirements of the project changed :
The new req is the app be able to view and design Crsytal 2008.
I will be opening a new qery since  - I need to clarify few points in this hurry to deliver the project - deadline on Tuesday.
I am closing this thread with thanks.
Pls if you can have a look at the other one ?, I will title it as
"How can I use Crystal reports version 2008 Viewer and designer in Visual Studio 2008 C# "
as for the reports being saved, I do not have control over it. My applicaiton allows the reports to be viewed , and designed by any third party. So I must assume the reports can come with or without data.