?
Solved

No data is displayed in my Crystal Report???

Posted on 2006-11-28
7
Medium Priority
?
1,182 Views
Last Modified: 2012-06-21
Hi, I'm using VS 2005, .net 2.0 and C#.  I developed my crystal report using the developer version, 11.0 and then add the report to my proejct.  In my project, I have a winform that has a CrystalReportViewer control on it.  I would like to use this form to produce report preview for all the reports in my project.  So, I would like to assign different reprotPath to the CrystalReportViewer control and also different dataset.  

For my first report, I created a dataset in my proejct, dsEventLog.xsd.  I created a table in this dataset in the designer with the columns.  I use the following code to run my report but the crystal report displays none of the data that I entered as rows in my code to this dataset's table.  What am I doing wrong here?  Thanks.




        private void btnOK_Click(object sender, EventArgs e)
        {
            dsEventLog dsLog = new dsEventLog();
            String padEventType = null;          
           
            // Associate the instance of 'EventLog' with local System Log.
            EventLog padEventLog = new EventLog("Directory Service", ".");

                padEventType = "Information";

            EventLogEntryCollection padLogEntryCollection = padEventLog.Entries;
            int logCount = padLogEntryCollection.Count;
            string user;
            // Iterate through all 'EventLogEntry' instances in 'EventLog'.
            for (int i = logCount - 1; i > 0; i--)
            {
                System.Diagnostics.EventLogEntry padLogEntry = padLogEntryCollection[i];
                // Select the entry having desired EventType.
                if (padLogEntry.EntryType.ToString().Equals(padEventType))
                {
                    DataRow dr = dsLog.Tables[0].NewRow();
                    dr["Date"] = padLogEntry.TimeGenerated.ToShortDateString();
                    dr["Time"] = padLogEntry.TimeGenerated.ToShortTimeString();
                    dr["Source"] = padLogEntry.Source.ToString();
                    dr["Category"] = padLogEntry.Category.ToString();
                    dr["Event"] = padLogEntry.InstanceId.ToString();
                    if (padLogEntry.UserName == null)
                        user = "N/A";
                    else
                        user = padLogEntry.UserName.ToString();
                    dr["User"] = user;
                    dr["Computer"] = padLogEntry.MachineName.ToString();
                    //string[] logItem =
                    //dr.ItemArray = new string[] { padLogEntry.TimeGenerated.ToShortDateString(),
                    //    padLogEntry.TimeGenerated.ToShortTimeString(), padLogEntry.Source.ToString(),
                    //    padLogEntry.Category.ToString(), padLogEntry.InstanceId.ToString(),
                    //    padLogEntry.UserName.ToString(), padLogEntry.MachineName.ToString()}; ;
                    dsLog.Tables[0].Rows.Add(dr);                
                }
            }
            int rows = dsLog.Tables[0].Rows.Count;
            ReportPreview logPreview = new ReportPreview();
            string reportPath = Application.StartupPath + "\\" + "EventLogReport.rpt";
            logPreview.crViewer.ReportSource= reportPath;

            logPreview.crViewer.Refresh();
            logPreview.crViewer.RefreshReport();

            if (ckbPreview.Checked == true)
            {
                logPreview.ShowDialog();
            }
            else
            {
                logPreview.crViewer.PrintReport();
            }
            //myDoc.Dispose();
            logPreview.Dispose();

            //All done, clean up
            dsLog.Tables.Clear();
            dsLog.Dispose();
            GC.Collect();
            Cursor = Cursors.Default;

        }
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 18034087
Are you using CR XI Release 2?  It is required for using Crystal XI with VS 2005

http://www.businessobjects.com/products/reporting/crystalreports/compatibility_vs2005.asp

mlmcc
0
 

Author Comment

by:lapucca
ID: 18034640
Yes I am using release 2.  Thank you.
0
 

Author Comment

by:lapucca
ID: 18034659
I debug through my application and can confirm that there are several rows of data created and inserted in the table, dtLog.  That's what makes this confusing for me.  Thanks.
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 101

Expert Comment

by:mlmcc
ID: 18038249
I don't see where you are associating the new dataset to the report.

mlmcc
0
 

Author Comment

by:lapucca
ID: 18038833
In my CR I assign the datasaet  dsEventLog.xsd as the source.  Do I need to something else in the c# code for this?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 18039075
I don't know since I don't use xsd files.

mlmcc
0
 
LVL 13

Accepted Solution

by:
EwaldL earned 2000 total points
ID: 18063931
You need to instantiate a report object
Then pass your dataset to a table of that report object using the setdatasource method.

This document here should explain it all
http://support.businessobjects.com/communityCS/TechnicalPapers/rtm_reportingoffadonetdatasets.pdf
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 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