Solved

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

Posted on 2004-10-04
5
258 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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