0
我有一個客戶端應用程序,它在Crystal Reports 2011 ReportViewer對象上設置一些參數和報告源,並且我想捕獲錯誤消息並顯示有意義的錯誤。在C#中捕獲Crystal Reports異常的示例代碼
我有一個客戶端應用程序,它在Crystal Reports 2011 ReportViewer對象上設置一些參數和報告源,並且我想捕獲錯誤消息並顯示有意義的錯誤。在C#中捕獲Crystal Reports異常的示例代碼
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);
}
}
http://msdn.microsoft.com/en-us/library/aa288423(v=vs.71).aspx –
你可以發佈你的代碼嗎? – HichemSeeSharp