I tried using NCReport in my application as a component for reporting services. I am using Visual Studio 2008 and Qt 4.5.3 for development and I have also installed a specially build version of NCReport compatible to Qt 4.5.3. Since I have VS solution, so my projects are not .pro and are .vcproj.
Instead of editing my .vcproj I have added the necessary dlls (ncreport2.dll, ncreportd2.dll), included the include folder, added the necessary library and also copied some of the dlls available in the (NCREPORT INSTALL FOLDER)/bin directory to my projetc's debug directory.
Now my code is
report = new NCReport();
report->reset(true);
QDir::separator() + "reports" + QDir::separator() + "MitigationAnalysis.xml"));
output = 0;
output = new NCReportPreviewOutput();
output->setAutoDelete( false );
report->setOutput(output);
report->runReport();
if(!report->hasError())
{
pv = new NCReportPreviewWindow();
pv->setReport( report );
pv->setOutput((NCReportPreviewOutput *) output);
pv->setWindowModality(Qt::ApplicationModal);
pv->setAttribute(Qt::WA_DeleteOnClose);
pv->show();
}
else if( report->hasError())
{
bool error = report->hasError();
QMessageBox::about(this,
"Error in Report", report
->lastErrorMsg
());
}
report = new NCReport();
report->reset(true);
report->setReportFile(QString(QApplication::applicationDirPath() +
QDir::separator() + "reports" + QDir::separator()
+ "MitigationAnalysis.xml"));
output = 0;
output = new NCReportPreviewOutput();
output->setAutoDelete( false );
report->setOutput(output);
report->runReport();
if(!report->hasError())
{
pv = new NCReportPreviewWindow();
pv->setReport( report );
pv->setOutput((NCReportPreviewOutput *) output);
pv->setWindowModality(Qt::ApplicationModal);
pv->setAttribute(Qt::WA_DeleteOnClose);
pv->show();
}
else if( report->hasError())
{
bool error = report->hasError();
QMessageBox::about(this,"Error in Report", report->lastErrorMsg());
}
To copy to clipboard, switch view to plain text mode
When I try to run this code the program throws and Access Violation Exception reading location........ and breaks at the line report->runReport(). No other information and I get confused about what to do.
Now, accidentally I tried to change the Filename of report and gave some wrong input string to it , and what I see is that the program doesn't break and shows me the last error message occurred in the report.
I am unable to understand this behavior. I am developing my application on WINDOWS XP (service pack 3). Please guide me if any one has faced the same problem or do me this favor.
Thanks
Bookmarks