Solved

Problem with Crystal Report in c# (Windows Form).....

Posted on 2004-10-04
5
254 Views
Last Modified: 2008-03-17
Hi Experts,
   
         I am trying to use Crystal Report in windows form in C#.
If I design everything at design time and then run the program then it is coming fine. But my requirment is to get the data at run time. In this case it is not giving any error, but not showing the report also. Repost viewer is blank.

Following is the snippet which, I am using.
              Here EstimatedHikeDetails  is report class.

               EstimatedHikeDetails rptEstimate = new EstimatedHikeDetails();
      SqlDataAdapter sqlAdapt = new SqlDataAdapter(" select * from estimatedresourcedetails ",sqlConn);
      DataSet dsNew = new DataSet();
      sqlAdapt.Fill(dsNew, "BU");
      sqlConn.Close();
      rptEstimate.SetDataSource(dsNew);
                  
      crystalReportViewer2.ReportSource = rptEstimate;
      crystalReportViewer2.Refresh();


Is this the correct way or wrong. And if this is wrong then can you please help me out...

Thanks
Bharat
0
Comment
Question by:bharat_mane
5 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 25 total points
ID: 12224335
Can u verify if the Report file EstimatedHikeDetails  is populated correctly?

You can also check one more option of Getting the Report file into ReportDocument and then set the ReportSource of the Viewer to this ReportDocument.

The link below gives the different methods of setting a ReportSource

http://www.c-sharpcorner.com/Code/2003/Oct/CrystalReportsViewer.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlmn/html/crsamreportbindingoptionsforwindowsformsviewers.asp
0
 
LVL 3

Assisted Solution

by:skpatra
skpatra earned 25 total points
ID: 12225926
You can use the Report Document Model (though I dont know why your code does not work). Do the followings:
1. Add reference to CrystalDecisions.CrystalReports.Engine.
1. Use ReportDocument object to load your rpt file.
        ReportDocument oDoc = new ReportDocument();
        oDoc.Load("C:\\MyFolder\\MyReport.rpt");
2. Attach the dataset
        SqlDataAdapter sqlAdapt = new SqlDataAdapter(" select * from estimatedresourcedetails ",sqlConn);
     DataSet dsNew = new DataSet();
     sqlAdapt.Fill(dsNew, "BU");
     sqlConn.Close();
     oDoc.SetDataSource(dsNew);
3. Assign the report document to the viewer
     crystalReportViewer2.ReportSource = oDoc;
     crystalReportViewer2.Refresh();
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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

22 Experts available now in Live!

Get 1:1 Help Now