Viewer显示空白页面

时间:2016-09-13 06:50:44

标签: c# c++ crystal-reports activex powerbuilder

我们使用PBNI使用C ++ DLL和Crystal Reports 10在C#中调用方法和打开窗口。

包含Crystal Reports Viewer OLE控件的窗口只显示空白页面,没有错误。在Powerbuilder的调试模式下,报告正确显示。 (打印和导出数据但不起作用。)

使用Process Monitor,我们可以看到C#可执行文件寻找并找到许多Crystal Reports dll(包括crviewer.dll) - 报告应该通过ODBC连接到Oracle数据库。咨询Oracle SQL历史记录,我认为查看器无法连接到数据库。但是当我更改连接凭据(别名,id ...)并尝试在报告中获取SQLQueryString时,我有一个错误(因此凭据是正确的。)

The report blank page with PBNI

The same report in debug mode (functional)

Powerbuilder代码(窗口的打开事件):

OLEObject APP_CR, APPLICATION
OLEObject CONNECTION_INFO
APPLICATION = CREATE OLEObject
long li_ret
li_ret = APPLICATION.ConnectToNewObject('CrystalRuntime.Application.10')    
APP_CR = APPLICATION.OpenReport("C:\Apps\PB120\HeliosII\Dev\Etat\CLI_LST.rpt", 1)   
CONNECTION_INFO = APP_CR.database.tables[1].ConnectionProperties
CONNECTION_INFO.DeleteAll
CONNECTION_INFO.Add("DSN","DATABASE O10")
CONNECTION_INFO.Add("Database", "DATABASE") 
CONNECTION_INFO.Add("User ID","ETAT")
CONNECTION_INFO.Add("Password","ETAT")  

// Testing the connection
string ls_SQLQuery
ls_SQLQuery = APP_CR.SQLQueryString
APP_CR.SQLQueryString = ls_SQLQuery

// Showing the report
ole_CRViewer.object.ReportSource(App_CR)    
ole_CRViewer.object.ViewReport

C ++ Dll代码(调用打开窗口的函数)

pbgroup group = session->FindGroup("nvo_lanceur", pbgroup_userobject);      
if (group == NULL) return false;

pbclass cls = session->FindClass(group, "nvo_lanceur");
if (cls == NULL) return false;

pbobject pbobj = session->NewObject(cls);
if (pbobj == NULL) return false;

pbmethodID mid = session->GetMethodID(cls, "of_traitermessage", PBRT_FUNCTION, "QS");

PBCallInfo ci;
session->InitCallInfo(cls, mid, &ci);

ci.pArgs->GetAt(0)->SetString(parameters);

// Call the function
try
{
    session->InvokeObjectFunction(pbobj, mid, &ci);

    // Was PB exception thrown?
    if (session->HasExceptionThrown())
    {
        // Handle PB exception
        session->ClearException();
    }
}
catch (...)
{
    // Handle C++ exception
}

“nvo_lanceur”对象的“of_traitermessage”函数调用包含查看器的窗口的Open(以及许多其他窗口,具体取决于参数。)C#应用程序调用C ++方法100ms,称为“会话 - > ProcessPBMessage();”用于调度powerbuilder事件消息。如何显示此报告?

0 个答案:

没有答案