Solved

No data is displayed in my Crystal Report???

Posted on 2006-11-28
7
1,176 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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 500 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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

726 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