我有一个客户端应用程序,它在Crystal Reports ReportView对象上设置一些参数和报告源,我想捕获错误消息并显示有意义的错误。
答案 0 :(得分:2)
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);
}
}