Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# ASP.Net MVC Entity Framework: Unable to connect to the SQL database for cache dependency registration. 2 52
SqlDataBase 7 53
Hey!! 5 37
Printing 1 58
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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