C# 捕获C中Crystal Reports异常的示例代码#
我有一个客户端应用程序,可以在crystal reports 2011 ReportViewer对象上设置一些参数和报告源,我希望捕获错误消息并显示有意义的错误C# 捕获C中Crystal Reports异常的示例代码#,c#,crystal-reports,C#,Crystal Reports,我有一个客户端应用程序,可以在crystal reports 2011 ReportViewer对象上设置一些参数和报告源,我希望捕获错误消息并显示有意义的错误 private void button1_Click(object sender, System.EventArgs e) { try { ReportDocument report = new ReportDocument(); report.Load ("c:\\sample.rpt");
private void button1_Click(object sender, System.EventArgs e)
{
try
{
ReportDocument report = new ReportDocument();
report.Load ("c:\\sample.rpt");
report.PrintToPrinter (1,true,1,2);
}
catch (LogOnException engEx)
{
MessageBox.Show _
("Incorrect Logon Parameters. Check your user name and password.");
}
catch (DataSourceException engEx)
{
MessageBox.Show _
("An error has occurred while connecting to the database.");
}
catch (EngineException engEx)
{
MessageBox.Show (engEx.Message);
}
}