Solved

No data is displayed in my Crystal Report???

Posted on 2006-11-28
7
1,143 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
  • 3
  • 3
7 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
Yes I am using release 2.  Thank you.
0
 

Author Comment

by:lapucca
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 100

Expert Comment

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

mlmcc
0
 

Author Comment

by:lapucca
Comment Utility
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 100

Expert Comment

by:mlmcc
Comment Utility
I don't know since I don't use xsd files.

mlmcc
0
 
LVL 13

Accepted Solution

by:
EwaldL earned 500 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now