Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

911 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

21 Experts available now in Live!

Get 1:1 Help Now