Displaying Crystal Reports using WinForms and C#
page 5 of 7
by Eric Landes
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 69235/ 131

Logging on using the CrystalViewer

Now let's look into setting the connection info using the Crystal Viewer object.  This is great if you are always using the same report in the Crystal Viewer object.  If you want to use the Viewer to display more than one report, the Report Document method probably makes more sense to use.  See Listing 2 for the C# code that sets the connection information on CrystalViewer1.

Listing 2

CrystalDecisions.Shared.ConnectionInfo crDbConnection = new
crDbConnection.IntegratedSecurity = true;
crDbConnection.DatabaseName = "TfsWorkItemTracking";
crDbConnection.ServerName = "tfdbserver";
CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt =
CrystalDecisions.CrystalReports.Engine.Database crDatabase = oRpt.Database;
CrystalDecisions.Shared.TableLogOnInfo oCrTableLoginInfo;
foreach (CrystalDecisions.CrystalReports.Engine.Table oCrTable in
  oCrTableLoginInfo = oCrTable.LogOnInfo;
  oCrTableLoginInfo.ConnectionInfo = crDbConnection;

As we can see, the connection information setting is pretty much the same.  We actually do use a Report Document object to help in setting the database.  We do this by Casting the report viewer reportsource to the ReportDocument object.  Once that is done, everything else is similar to the last section.

View Entire Article

User Comments

No comments posted yet.

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2020 ASPAlliance.com  |  Page Processed at 2020-01-23 3:33:02 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search