0

我有一个客户端应用程序,它在水晶报表 2011 ReportViewer 对象上设置一些参数和报表源,我想捕获错误消息并显示有意义的错误。

4

1 回答 1

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);
   }
}
于 2012-06-28T05:46:51.283 回答