Crystal Reports -- Creating s new report at runtime.
-
I am working with crystal reports 10 in vc++ 6.0 and need to create a new report. I am using the following piece of code.
#import "craxdrt.dll" no_namespace IApplicationPtr m_pApplication; IReportPtr m_pReport;
....m_pApplication.CreateInstance("CrystalRuntime.Application");
.... Everyting goes fine till here. But as soon as i call the NewReport() method in the IApplicationPtr it throws a com exception.m_pReport = m_pApplication->NewReport()
throws a com exception. Dont know whats going wrong. -
I am working with crystal reports 10 in vc++ 6.0 and need to create a new report. I am using the following piece of code.
#import "craxdrt.dll" no_namespace IApplicationPtr m_pApplication; IReportPtr m_pReport;
....m_pApplication.CreateInstance("CrystalRuntime.Application");
.... Everyting goes fine till here. But as soon as i call the NewReport() method in the IApplicationPtr it throws a com exception.m_pReport = m_pApplication->NewReport()
throws a com exception. Dont know whats going wrong.I'm assuming your CreateInstance has failed. What is the HResult returned from it. I usually create a Crystal instance using
HRESULT hr = m_Application.CreateInstance(__uuidof(Application));
What exception is thrown? Have you added an exception handler to get more details of the exception?try { m_pReport = m_pApplication->NewReport(); } catch(_com_error& e) { TRACE("COM Error: %s %s %x\n", e.ErrorMessage(), (LPCTSTR)e.Description(), e.Error()); }
Michael CP Blog [^]