// Assign to CrystalReportViewer crystalReportViewer1.ReportSource = report;
// Set database logon info ConnectionInfo connInfo = new ConnectionInfo(); connInfo.ServerName = "YOUR_SQL_SERVER"; connInfo.DatabaseName = "YourDatabase"; connInfo.UserID = "yourUser"; connInfo.Password = "yourPassword"; crystal reports runtime
// Apply to all tables foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables) { TableLogOnInfo logOnInfo = table.LogOnInfo; logOnInfo.ConnectionInfo = connInfo; table.ApplyLogOnInfo(logOnInfo); } // Assign to CrystalReportViewer crystalReportViewer1
using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; // Load the report ReportDocument report = new ReportDocument(); report.Load(@"C:\Reports\MyReport.rpt"); connInfo.ServerName = "YOUR_SQL_SERVER"
Requires CrystalDecisions.CrystalReports.Engine and CrystalDecisions.Shared DLLs (SAP Crystal Reports runtime for .NET).
Comments