Reputation: 777
I have a client application that sets some parameters and report source on a crystal reports 2011 ReportViewer object and I want to catch error messages and display meaningful errors.
Upvotes: 0
Views: 2342
Reputation: 2677
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);
}
}
Upvotes: 2